Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Detect mac M1 cpu programmatically

I have to implement different logic between normal(?) mac cpu and m1 cpu.

But I don't know how can I detect that.

like image 834
Henry Lee Avatar asked Dec 17 '25 21:12

Henry Lee


1 Answers

Under the assumption that M1 is the only arm64 chip that runs OSX then you can use:

var isArm = System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture == Architecture.Arm64;
var isOSX = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
var isM1 = isArm && isOSX;
like image 175
Alby Avatar answered Dec 19 '25 13:12

Alby



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!