Format
(1)
String
(1)

Format

22-Apr-06 03:01 AM
Hai All,



I am working in asp.net...



I need to format a number in the following manner...



number  = 500



After formatting i need the number as string as "     500"



that is 5 spaces before number...



If give the number as 2, then i should get as "       2"  i.e 7



spaces before the number..



how can format like this??



Please reply...



Looking forward for the response...



Thanx in advance.....

Format

22-Apr-06 05:41 AM
You can use the PadLeft method to get the formatting you need:



int i = 100;

string s = i.ToString().PadLeft(8, ' ');



will give you a string 8 characters long, with i right justified, so in

this case there will be five spaces before the number.



*** Sent via Developersdex http://www.developersdex.com ***
Post Question To EggHeadCafe