Thursday, September 30, 2010

Find the time elapsed between two statements C#

This was some thing i got to learn yesterday. I was using some profiler and some random ways to get the time. but this was a quick one. I knew something like this existed but never bothered until I had to use it

There is a Stopwatch class in c# that does that for you.

all you need to do is

Stopwatch sw = new Stopwatch();
sw.Start();
Debug.WriteLine(sw.ElapsedMilliseconds.ToString());
sw.Stop();


No comments: