I have been looking high and low for a solution to this, but although the question has been asked before the answers no longer apply to .NET Standard 1.5 and its cross-platform way of thinking. Also, this question is about the OS Architecture not the .NET platform architecture.
What I Tried
- Using C#, how to get whether my machine is 64bit or 32bit?
- How to detect Windows 64-bit platform with .NET?
The best answer, Environment.Is64BitOperatingSystem is an API that is not implemented in .NET Standard 1.5.
The answer
/// <summary>Is64s the bit operating system.</summary>
/// <returns></returns>
if (IntPtr.Size == 8)
// 64Bit
else
// 32bit
is not what I need. Although still possible to do in .NET Standard, it determines the bitness of the .NET platform, not the underlying OS.
Nearly all of the other replies are using [DllImport("kernel32.dll")]
, which I am almost certain won't work on anything but Windows.
Question
So, how do I determine the bitness of the underlying OS for all of the platforms that .NET Standard 1.5 supports (Linux, iOS, Windows, Android, etc.)?