This documentation is archived and is not being maintained.

Environment.ProcessorCount Property

Gets the number of processors on the current machine.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public static int ProcessorCount { get; }

Property Value

Type: System.Int32
The 32-bit signed integer that specifies the number of processors on the current machine. There is no default.

The following code example demonstrates the ProcessorCount property.

// This example demonstrates the  
//     Environment.ProcessorCount property. 
using System;

class Sample 
{
    public static void Main() 
    {
    Console.WriteLine("The number of processors " +
        "on this computer is {0}.", 
        Environment.ProcessorCount);
    }
}
/*
This example produces the following results:

The number of processors on this computer is 1.
*/

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

XNA Framework

Supported in: 3.0, 2.0, 1.0
Show: