- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
//calculate elapsed time
TimeSpan elapsed = DateTime.Now - startTime;
//if a second has elapsed
if (lastSecond != elapsed.Seconds)
{
//store last second
lastSecond = elapsed.Seconds;
//get hours
string hours;
if (elapsed.Hours < 10)
hours = "0" + elapsed.Hours.ToString();
else
hours = elapsed.Hours.ToString();
//get minutes
string minutes;
if (elapsed.Minutes < 10)
minutes = "0" + elapsed.Minutes.ToString();
else
minutes = elapsed.Minutes.ToString();
//get seconds
string seconds;
if (elapsed.Seconds < 10)
seconds = "0" + elapsed.Seconds.ToString();
else
seconds = elapsed.Seconds.ToString();
//update label
this.lblElapsedTime.Text = "Elapsed time: " + hours + ":" + minutes + ":" + seconds;
}
sayidandrtfm 10.08.2011 10:06 # 0
Явно то, что автор(кода) не обладает качеством программиста "умеренная лень".