Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Environment.OSVersion Property

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

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

Public Shared ReadOnly Property OSVersion As OperatingSystem
Dim value As OperatingSystem

value = Environment.OSVersion

/** @property */
public static OperatingSystem get_OSVersion ()

public static function get OSVersion () : OperatingSystem

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 for Pocket PC, Windows Mobile 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
Imports System

Class Sample
   Public Shared Sub Main()
      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

// 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 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

© 2015 Microsoft