Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Padding right using string format
Message
From
09/12/2007 12:57:22
 
 
To
09/12/2007 07:43:37
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01274270
Message ID:
01274298
Views:
28
Almost got it ... instead of:
string y = string.Format(x.PadRight(50, ' '), lcDescription);
you need this:
string y = string.Format(x, lcDescription).PadRight(50, ' ');
~~Bonnie


>>Hi,
>>I have string format expression as below:
>>
>>
string.Format("Total {0} Amount:", lcDescription);
>>
>>How could make the string expression above (after evaluated) to have fixed length?
>>
>>Thank you
>
>You could use PadLeft or PadRight, something like:
>
>string lcDescription = "abc";
>string x = "Total {0} Amount:" ;
>string y = string.Format(x.PadRight(50, ' '), lcDescription);
>
>
>In the Example above, y would be:
>
>"Total abc Amount:                                 "
after evaluation.
>
>Joaquim
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform