Posts

Showing posts from September, 2016

How to calculate the run time/time required for a program in visual studio or in C Sharp

I recently started programming in C# and I found it far better than Java already. To find the time took by your code , you will have to insert the below snippet . For more information, you can go to the msdn link. /* importing the lib*/ using System.Diagnostics; /* creating the object of Stopwatch, where we can it to calculate the time*/ Stopwatch stopwatch = new Stopwatch (); stopwatch.Start();// Start the time stopwatch.Stop();// Stop the time TimeSpan ts = stopwatch.Elapsed;             long elapsedMilliseconds;             elapsedMilliseconds = stopwatch.ElapsedMilliseconds; /*Conversion of elapsed time to milliseconds. We can even convert it in to minutes or hours. For more information please check the below link to msdn*/ Console .WriteLine( "RunTime " + elapsedMilliseconds); Msdn Link