System.Environment.OSVersion on windows, linux and mac osx
using System;
Console.WriteLine(Environment.OSVersion);
// on windows output is like:
// Microsoft Windows NT 6.2.9200.0, windows build number included
// on linux output is like:
// Unix 3.8.0.19, linux kernel included.
// on osx output like is like:
// Unix 13.0.0.0, mac version.