Home »
.Net »
C# Programs
C# program to get the number of milliseconds elapsed since system started using Environment class
Here, we are going to learn how to get the number of milliseconds elapsed since system started using Environment class in C#.Net?
Submitted by Nidhi, on April 23, 2021
To get the number of milliseconds elapsed since the system started using the Environment class – we use the TickCount property. This property returns an integer value that denotes the number of milliseconds elapsed since the system stated.
Syntax:
int Environment.TickCount
Program:
The source code to get the number of milliseconds elapsed since system started using Environment class is given below. The given program is compiled and executed successfully.
using System;
class Sample
{
//Entry point of Program
static public void Main()
{
int tickCount = 0;
tickCount = Environment.TickCount;
Console.WriteLine("Tick Count: "+tickCount);
}
}
Output:
Tick Count: 3228690
Press any key to continue . . .
C# Environment Class Programs »