Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Padding right using string format
Message
From
09/12/2007 07:43:37
 
 
To
09/12/2007 07:22:35
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:
01274271
Views:
25
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform