int a = 1;
string s = a.ToString();
string s2 = s.PadLeft(8, '0');
The PadLeft() method aligns to the right the characters in your original
string and inserts in the left the specified character (in this case '0')
until the strings reaches the specified length (8).
This method is overloaded:
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.