C# program to get the total number of cores on a computer


Use the Environment.ProcessorCount to get the total number of cores on a computer −

Environment.ProcessorCount

The following is the code that displays the total number of cores on a computer in C# −

Example

Using System;
namespace Demo {
   class Program {
      static void Main(string[] args) {
         Console.WriteLine(Environment.ProcessorCount);
      }
   }
}

Updated on: 22-Jun-2020

134 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements