Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Program to set the timer to zero
To set the timer information to zero, use the Stopwatch Restart method.
Firstly, begin the Stopwatch −
Stopwatch s = Stopwatch.StartNew();
Then, use Restart() to set the timer to zero −
s.Restart();
Let us see the complete code −
Example
using System;
using System.Threading;
using System.Diagnostics;
public class Demo {
public static void Main() {
Stopwatch s = Stopwatch.StartNew();
Thread.Sleep(500);
// restart
s.Restart();
// begin again
Thread.Sleep(500);
Console.WriteLine(s.Elapsed);
}
}
Output
00:00:00.5004937
Advertisements