Quickest way:
if(IntPtr.Size == 8) { // 64 bit machine} else if(IntPtr.Size == 4) { // 32 bit machine}
Note: this is very direct and works correctly on 64-bit only if the program does not force execution as a 32-bit process (e.g. through <Prefer32Bit>true</Prefer32Bit>
in the project settings).