I made timer, which outputs time like this:
0:1, 0:2, 0:3 ... 0:10 ...
string.Format("{0}:{1}", hours, minutes);
But I want to output as follows:
00:01, 00:02, 00:03
How about reading the .NET documentation at http://msdn.microsoft.com/en-us/library/system.string.format.aspx ? Many working samples already provided by others...
In C# to have leading Zero you can use Format :
intValue.ToString("00.##");
So, if you want to have your minute and second with leading zero you can use:
string.Format("{0}:{1}", hours.ToString("00.##"), minutes.ToString("00.##"));
If your timer use the TimeSpan object you can use the Format for the TimeSpan:
myTimeSpan.Format("hh:mm");