.net core check if linux

C#
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
    Console.WriteLine("We're on macOS!");
}

Source

Also in C#: