C#: Measure execution time of a method using System.Diagnostics.Stopwatch

One of the easiest ways of measuring the execution time of a method is to use System.Diagnostics.Stopwatch

Suppose you have a method called GetEmployees() and you want to check the execution time of this method. You can do that by using the following code:
Stopwatch watch = Stopwatch.StartNew();

Console.WriteLine(String.Format("{0} {1} ms", "GetEmployees", watch.ElapsedMilliseconds));

In case the application is not a Console application like ASp.net application you can use Debug.WriteLine instead of Console.WriteLine and run the application in debug mode and click on View Output to see the results.