- 
        1. Re: Is there a way to determine the operating system from within a C# program?saravanan.subramaniam Jun 29, 2016 12:56 AM (in response to tnolan)using System; class Sample { public static void Main() { Console.WriteLine(); Console.WriteLine("OSVersion: {0}", Environment.OSVersion.ToString()); } } /* 
 This example produces the following results:
 OSVersion: Microsoft Windows NT 5.1.2600.0
 */
- 
        2. Re: Is there a way to determine the operating system from within a C# program?donschenck Jul 5, 2016 3:19 PM (in response to saravanan.subramaniam)The above code works well in Windows, but in RHEL it throws the error "error CS0117: 'Environment' does not contain a definition for 'OSVersion'" The following code works with any operating system: using System; using System.Runtime.InteropServices; namespace ConsoleApplication { public class Program { public static void Main(string[] args) { Console.WriteLine(System.Runtime.InteropServices.RuntimeInformation.OSDescription.ToString()); Console.WriteLine(System.Runtime.InteropServices.RuntimeInformation.OSArchitecture.ToString()); } } } 
 
     
    