Wednesday, January 5, 2011

TimeSpan Calculation

If you ever want to calculate the difference between two points of time …

 

 

DateTime startTime = DateTime.Now;

 

…. Your code comes here …..

 

TimeSpan elapsedTime = DateTime.Now - startTime;

 

string TimeSpent = elapsed.ToString(); // ##:##:##

 

 

No comments:

Post a Comment