I am trying to print digits like 0101…. 1231, where first two digits are months and next two are days. I did this:
int d, m;
for (m = 01; m <= 12; m++)
for (d = 01; d <= 31; d++)
Console.WriteLine(loc + m.ToString() + d.ToString());
// Directory.CreateDirectory(loc + m.ToString() + d.ToString());
This is printing digits like 11 instead of 0101. How can I print integers 1 through 9 as 01-09?
See Standard Numeric Format Strings [MSDN] for reference.
Although:
would give you more convenient control over output date format, and help you to avoid printing out dates that do not exist (such as 31 Apr or 30 Feb)
See DateTime.ToString Method (String) [MSDN] for reference.