Placing leading Zeros to numbers

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

this will return
000100

int yourNumber = 75;
Console.WriteLine(yourNumber.ToString("D5", CultureInfo.InvariantCulture));

this will return
00075

Comments or Responses

Login to post response