Languages
[Edit]
EN

C#/.NET - get number of processors on the current machine

9 points
Created by:
Root-ssh
175500

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.

 

References:

  1. Environment.ProcessorCount Property - Microsoft Docs
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join