Export (0) Print
Expand All

Environment.OSVersion Property

Gets an OperatingSystem object that contains the current platform identifier and version number.

[Visual Basic]
Public Shared ReadOnly Property OSVersion As OperatingSystem
[C#]
public static OperatingSystem OSVersion {get;}
[C++]
public: __property static OperatingSystem* get_OSVersion();
[JScript]
public static function get OSVersion() : OperatingSystem;

Property Value

An OperatingSystem object.

Exceptions

Exception Type Condition
ExecutionEngineException This property was unable to obtain the system version.

-or-

The platform identifier is not a member of PlatformID.

Remarks

.NET Compact Framework Platform Note:  The version revision field for this property is always -1.

Example

[Visual Basic] 
' Sample for the Environment.OSVersion property
Imports System

Class Sample
   Public Shared Sub Main()
      Console.WriteLine()
      Console.WriteLine("OSVersion: {0}", Environment.OSVersion.ToString())
   End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'
'OSVersion: Microsoft Windows NT 5.1.2600.0
'

[C#] 
// Sample for the Environment.OSVersion property
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
*/

[C++] 
// Sample for the Environment::OSVersion property
#using <mscorlib.dll>

using namespace System;

int main() {
   Console::WriteLine();
   Console::WriteLine(S"OSVersion: {0}", Environment::OSVersion);
}
/*
This example produces the following results:

OSVersion: Microsoft Windows NT 5.1.2600.0
*/

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

Environment Class | Environment Members | System Namespace

Show:
© 2014 Microsoft