How I print in a textbox or at the output the time that the program spend running?
I want it to be displayed into a for-loop, to get how much time each for-loop needs.
You could try:
DateTime dt = DateTime.Now;
for (.......)
{
}
TimeSpan ts = DateTime.Now - dt;
textbox1.Text = ts.TotalMilliseconds.ToString();
or (according to MSDN) if you need better resolution
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
for (.......)
{
}
stopWatch.Stop();
textbox1.Text = stopWatch.ElapsedMilliseconds.ToString();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With