In C# I have an integer value which need to be convereted to string but it needs to add zeros before:
For Example:
int i = 1;
When
Here's a good example:
int number = 1; //D4 = pad with 0000 string outputValue = String.Format("{0:D4}", number); Console.WriteLine(outputValue);//Prints 0001 //OR outputValue = number.ToString().PadLeft(4, '0'); Console.WriteLine(outputValue);//Prints 0001 as well