C# Stopwatch Explained – How to Measure Code Execution Time?

C# Stopwatch is a powerful class provided by the .NET Framework that we can use to measure the execution time of a specific code block.
It is commonly used in performance testing and benchmarking applications to measure the time a code snippet takes to execute.

The Stopwatch class is part of the System.Diagnostics namespace and is available in all .NET programming languages, including C#.

C# Stopwatch