get system platform in csharp

To get the system platform in C#, you can use the System.Runtime.InteropServices.RuntimeInformation class. This class provides information about the current runtime and operating system platform.

Here's an example code snippet that demonstrates how to use this class to get information about the operating system platform:

main.cs
using System.Runtime.InteropServices;

// Get the operating system platform
var platform = RuntimeInformation.OSDescription;

// Print the platform to the console
Console.WriteLine($"Operating System Platform: {platform}");
224 chars
8 lines

This code uses the RuntimeInformation.OSDescription property to get a string that describes the operating system platform. For example, on Windows, this string might be "Microsoft Windows 10.0.18362".

gistlibby LogSnag