EN
C#/.NET - get number of processors on the current machine
9
points
In C#/.NET it is possible to get number of processors on the current machine using Environment.ProcessorCount
property.
Quick solution:
int processorCount = Environment.ProcessorCount;
Practical example
using System;
public class Program
{
public static void Main()
{
int count = Environment.ProcessorCount;
Console.WriteLine("Number of available processors is " + count + ".");
}
}
Example output:
Number of available processors is 4.