C# Program to Get the Operating System Version of Computer using Environment Class
In C#, Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that it retrieves command-line arguments information, exit codes information, environment variable settings information, contents of the call stack information, and time since the last system boot in milliseconds information. In this article, we are going to discuss how to get the operating system version of the computer. So we use the OSVersion property of the Environment class. This property returns the current OS version of the system or platform identifier. It will also return an InvalidOperationException if this property does not get the current version of the system or a platform identifier that is not part of PlatformID.
Return: It returns the platform identifier or the version of the system.
In the below example, using the OsVersion property of Environment class we find the current OS version of our computer system.
The current operating System version is Unix 22.214.171.124