string strI;
for(int i = 1;i<100;i++)
strI = i.ToString();
in here, if i is 1 then strI is '1'
But I want to get '01'
or '001'
it looks quite easy. but there's only article about datetime.tostring("yyyy-MM-dd") :(
string strI;
for(int i = 1;i<100;i++)
strI = i.ToString();
in here, if i is 1 then strI is '1'
But I want to get '01'
or '001'
it looks quite easy. but there's only article about datetime.tostring("yyyy-MM-dd") :(
i.ToString("00")
or
i.ToString("000")
depending on what you want
Look at the MSDN article on custom numeric format strings for more options: http://msdn.microsoft.com/en-us/library/0c899ak8(VS.71).aspx
This blog post is a great little cheat-sheet to keep handy when trying to format strings to a variety of formats.
link to trojan removed
Cheers
Dave
Edit*
The link was removed because Google temporarily warned that the site (or related site) may have been spreading malicious software. It is now off the list an no longer reported as problematic. Google "SteveX String Formatting" you'll find the search result and you can visit it at your discretion.