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 I convert it to string it needs to become 0001
I need to know the syntax in C#.
Here I want to pad my number with 4 digit. For instance, if it is 1 then it should show as 0001, if it 11 it should show as 0011.
Below is the code that accomplishes this:
reciptno=1; // Pass only integer.
string formatted = string.Format("{0:0000}", reciptno);
TxtRecNo.Text = formatted; // Output=0001
I implemented this code to generate money receipt number for a PDF file.