The things I learn working for the CLR team
In some of my tests, I need to check if I'm on a 64-bit machine or not. Yesterday, I spent some time looking through the System.Environment class or System.Diagnostics class to see if there was a static method or something that I could call to check if the machine I was on was a 64-bit machine. I was thinking to PInvoke to GetSystemInfo, but gosh darn it, there had to be an easier way! I talked to
Josh Williams again (is it hard to tell we hang out?), and he said to just do a IntPtr.Size (static method) and since IntPtr is designed to be an integer whose size is platform specific, it will be 8 if you are on a 64-bit machine and 4 if you are on a 32-bit machine. Duh! I was so amazed at how simple this was that I wanted to share it with y'all...
Anonymous comments are disabled