Code

using System;
using System.Runtime.InteropServices;

namespace TestDemo01
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            Console.WriteLine($"Linux:{ RuntimeInformation.IsOSPlatform(OSPlatform.Linux) }");
            Console.WriteLine($"Windows:{ RuntimeInformation.IsOSPlatform(OSPlatform.Windows) }");
            Console.WriteLine($"OSX:{ RuntimeInformation.IsOSPlatform(OSPlatform.OSX) }");

            Console.ReadKey();
        }
    }
}

效果

在这里插入图片描述

Other

在这里插入图片描述