Checking If the Operating System Is macOS in C# & .NET
[C#, .NET]
In a previous post, “Determining The Operating System C# .NET Program Is Running Under”, we looked at how to extract information about the operating system the code is running under.
There were a lot of candidate APIs:
There is actually a much simpler API if all you need is a quick check of whether the OS is macOS - the OperatingSystem.IsMacOS() API.
void Main()
{
Console.WriteLine(OperatingSystem.IsMacOS());
}
This, unsurprisingly, returns true or false, depending on where you are running.

If you need more granular checks, the other APIs mentioned earlier might be beneficial.
TLDR
OperatingSystem.IsMacOS() will tell you that your code is running on macOS.
Happy hacking!