Get the number of processors on the current machine in CSharp

Description

The following code shows how to get the number of processors on the current machine.

Example


//  w  ww .  jav  a2 s  . c  o  m
using System;

class Sample 
{
    public static void Main() 
    {
       Console.WriteLine("The number of processors " +
              "on this computer is {0}.", 
                Environment.ProcessorCount);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Development »




Console
Encoding
Environment
Random