C# Program to Get the Number of Milliseconds Elapsed Since System Started Using Environment Class
Last Updated :
24 Oct, 2021
In C#, Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that it retrieves command-line arguments information, exit codes information, environment variable settings information, contents of the call stack information, and time since the last system boot in milliseconds information. By just using some predefined methods we can get the information of the Operating System using the Environment class. Here In this article, we will get the number of milliseconds so we use the TickCount Property of the Environment class. TickCount property is used to get the number of milliseconds of the environment class from the starting. It will return the seconds in an integer format
Syntax:
int Environment.TickCount
Return Type: Returns number of elapsed seconds which is an integer
Example 1:
C#
using System;
class GFG{
static public void Main()
{
int summ = 2 + 3;
Console.WriteLine( "Sum is: " + summ);
Console.WriteLine( "So, the tick count is : " +
Environment.TickCount);
}
}
|
Output:
Sum is: 5
So, the tick count is : 12173138
Example 2:
C#
using System;
class GFG{
static public void Main()
{
Console.WriteLine( "The tick count is : " +
Environment.TickCount);
}
}
|
Output:
The tick count is : 11475417
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...