C# Environment ProcessorCount

.NET Framework information

What does the Environment ProcessorCount property do? Although processors can have multiple cores, the ProcessorCount property in the .NET Framework returns the total number of cores on a computer, not processors.

This C# Environment article demonstrates the ProcessorCount property.

Example

This program shows that the dual-core, single processor computer I execute it on returns 2 for ProcessorCount. Conceptually, you can consider these logical, but not physical, processors. The computer actually has only one physical processor.

Program that accesses ProcessorCount [C#]

using System;

class Program
{
    static void Main()
    {
	Console.WriteLine(Environment.ProcessorCount);
    }
}

Output

2

Summary

Note

The ProcessorCount property in the .NET Framework returns the number of logical processors in the executing computer. This means each core is considered a discrete processor, rather than part of a single processor. For this reason, you can use ProcessorCount for creating an array of Threads to use the computer's computational resources fully.

.NET Framework Info
.NET