This program will help you to add leading zero to a given number you can specify D5 if you want that total number of digits should be 5 including zeros.
C# Sample Code to Add Leading Zeros:
using System;
using System.Globalization;
namespace MyApp
{
class Leading_zero_class
{
static void Main()
{
int myAmount = 475;
Console.WriteLine(myAmount.ToString("D6", CultureInfo.InvariantCulture));
Console.WriteLine(myAmount.ToString("D5", CultureInfo.InvariantCulture));
Console.Read();
}
}
}
No comments:
Post a Comment