Using C#, how to get whether my machine is 64bit or 32bit?

后端 未结 6 1029
陌清茗
陌清茗 2021-02-19 14:23

Using C#, I would like to create a method that retunrs whether my machine is 64 or 32-bit.

Is there anybody who knows how to do that?

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-19 15:08

        public static string t2or64()
            {
                string t2s4;
                bool os = System.Environment.Is64BitOperatingSystem;
                int x = 0;
                if (os == true)
                {
                    x = 64;
                }
                else
                {
                    x = 32;
                }
    
                t2s4 = Convert.ToString(x);
                return t2s4;
            }
    

提交回复
热议问题