Format numbers as you wish

Madhu.b.rokkam
Posted by Madhu.b.rokkam under C# category on | Points: 40 | Views : 1432
int yourNumber = 125;
Console.WriteLine(yourNumber.ToString("00000", CultureInfo.InvariantCulture));

result
00125

int yourNumber = 125;
Console.WriteLine(yourNumber.ToString("00000.00", CultureInfo.InvariantCulture));

result
00125.00

double yourNumber = 12543.234;
Console.WriteLine(yourNumber.ToString("00,000.00", CultureInfo.InvariantCulture));

result
12,543.23

Comments or Responses

Login to post response