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 static OperatingSystem OSVersion { get; }
/** @property */
public static OperatingSystem get_OSVersion ()

public static function get OSVersion () : OperatingSystem

Property Value

An OperatingSystem object.

Exception typeCondition

InvalidOperationException

This property was unable to obtain the system version.

-or-

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
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
*/

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

class Sample
{
    public static void main(String[] args)
    {
        Console.WriteLine();
        Console.WriteLine("OSVersion: {0}", 
            System.Convert.ToString(Environment.get_OSVersion()));
    } //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

ADD
Show:
© 2014 Microsoft