Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
AppendFormat
Message
From
08/02/2013 15:44:44
John Baird
Coatesville, Pennsylvania, United States
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01565543
Message ID:
01565552
Views:
45
>Hi everybody,
>
>I am wondering what is the correct syntax for fomatting integer values in the C# to appear right justfied to predefined number of spaces?
>
>Here is my code
>
>
> location = (String)row["location"];
>                                onHand = Convert.ToInt32(row["on_hand"]);
>                                displayString.AppendFormat("  {0,-10} {1:N0}{2}", location, onHand, Environment.NewLine);
>
>which is supposed to simulate this VFP code
>
>
> lvRetVal=lvRetVal+'  '+padr(location,10)+' '+transform(on_hand, '999,999,999')+chr(13)+chr(10)
>
>Do you know how should I adjust the above?
>
>I looked at this page in MSDN
>http://msdn.microsoft.com/en-us/library/vstudio/system.globalization.numberformatinfo.numbergroupsizes(v=vs.100).aspx
>
>but still don't understand
>
>Thanks a lot in advance.
>
>UPDATE. I figured this out and visually my results look the same, but UnitTest is still failing.


I would use string.Format....
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform