Format

  • Thread starter Thread starter Wallace
  • Start date Start date
W

Wallace

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.....
 
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.
 
Back
Top