Skip to content
Related Articles
Open in App
Not now

Related Articles

C# Program to Check if Operating System is 64-bit OS or Not Using Environment Class

Improve Article
Save Article
  • Last Updated : 01 Nov, 2021
Improve Article
Save Article

Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that retrieves command-line arguments information, exit codes information, environment variable settings information, contents of the call stack information, and time since last system boot in milliseconds information. In this article, we will discuss how to check whether running operating systems is 64 bit OS or not using Environment class. So we need to use the Is64BitOperatingSystem property of the Environment class. This property is used to check whether the running operating system is based on 64-Bit architecture or not and returns true if it is 64-bit OS otherwise it will return false.



Return Type: The return type of this property is Boolean. It returns true if the OS is 64-bit OS. Otherwise, it will return false.



// C# program to check whether the given
// OS is 64-bit Os or not. Using the
// Environment class
using System;
class GFG{
static public void Main()
    // Declaring a variable of bool type
    // to store the result
    bool outresult;
    // Now we determine the current operating system 
    // is 64-bit OS or not. Using the Is64BitOperatingSystem
    // property of Environment class
    outresult = Environment.Is64BitOperatingSystem;
    // Display the result
    if (outresult == true)
        Console.WriteLine("Yes! the current operating " +
                          "system is 64-bit OS");
        Console.WriteLine("No! the current operating "
                          "system is not 64-bit OS");


Operating System is based 64-bit architecture

When we run the same code in the 32-bit system then the output will be:

Operating System is not based 64-bit architecture
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!