C# configuration architecture

Quick snippet to detect the configuration architecture (x86 or x64) in C#. The pointer size tells you which mode the process is running in — 8 bytes means a 64-bit process, 4 bytes means 32-bit.

private static bool is64BitConfiguration() {
	return System.IntPtr.Size == 8;
}

On any modern .NET (Framework 4+ onward, and all of .NET Core/.NET 5+) there’s a built-in for this: Environment.Is64BitProcess. The pointer-size trick above still works everywhere and is handy when you’re stuck on older runtimes or want zero dependencies — but prefer the framework API in new code, along with Environment.Is64BitOperatingSystem when you need to distinguish the process bitness from the OS bitness (they differ whenever a 32-bit process runs on 64-bit Windows).

Leave a Reply

Your email address will not be published. Required fields are marked *