This documentation is archived and is not being maintained.

Environment.OSVersion Property

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

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

static property OperatingSystem^ OSVersion {
	OperatingSystem^ get ();
/** @property */
public static OperatingSystem get_OSVersion ()

public static function get OSVersion () : OperatingSystem

Not applicable.

Property Value

An OperatingSystem object.

Exception typeCondition


This property was unable to obtain the system version.


The obtained platform identifier is not a member of PlatformID.

Windows Mobile 2003 for Pocket PC, Windows Mobile 2003 for Smartphone, Windows CE Platform Note: The version revision field for this property is always -1.

The following code example displays the platform identifier and version number of the computer that runs the code example.

// Sample for the Environment::OSVersion property
using namespace System;
int main()
   Console::WriteLine( "OSVersion: {0}", Environment::OSVersion );

This example produces the following results:

OSVersion: Microsoft Windows NT 5.1.2600.0

// Sample for the Environment.OSVersion property
import System.*;

class Sample
    public static void main(String[] args)
        Console.WriteLine("OSVersion: {0}", 
    } //main
} //Sample

This example produces the following results:

OSVersion: Microsoft Windows NT 5.1.2600.0

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0