How to do it...

  1. We will create a .NET Core console application in Visual Studio 2017. Under Visual C# templates, select .NET Core and a Console App (.NET Core) project:
  1. When you created your console application, the code will look as follows:
        using System;        class Program        {          static void Main(string[] args)          {            Console.WriteLine("Hello World!");          }        }
  1. Modify your code to look as follows:
        static void Main(string[] args)        {          Console.WriteLine("I can run on Windows, Linux and macOS");          GetSystemInfo();          Console.ReadLine();        }        private static void GetSystemInfo()        {          var osInfo = System.Runtime.InteropServices.RuntimeInformation.OSDescription; Console.WriteLine($"Current ...

Get C# 7 and .NET Core Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.