Get the number of milliseconds elapsed since the system started in CSharp

Description

The following code shows how to get the number of milliseconds elapsed since the system started.

Example


using System;//from ww w.j av a2s  .c  o m

class Sample 
{
    public static void Main() 
    {
        int result = Environment.TickCount & Int32.MaxValue;
        Console.WriteLine("TickCount: {0}", result);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Development »




Console
Encoding
Environment
Random