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(); // ##:##:##
The helping posts of different tips and tricks for development in ASP.net, WCF, Silverlight and RIA Services.
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(); // ##:##:##
If you ever want to round off a value in CSharp … you can always you Math.Round function …
e.g.
Math.Round(23.435321, 0) // this will round off the figure and remove all figures after decimal points.
J