OperatingSystem.Version Proprietà
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene un oggetto Version che identifica il sistema operativo.
public:
property Version ^ Version { Version ^ get(); };
public Version Version { get; }
member this.Version : Version
Public ReadOnly Property Version As Version
Oggetto Version che descrive il numero di versione principale, il numero di versione secondaria, la build e i numeri di revisione del sistema operativo.
Nell'esempio di codice seguente vengono creati diversi OperatingSystem oggetti e viene visualizzata la Version proprietà per ogni oggetto.
// Example for the OperatingSystem.Platform and
// OperatingSystem.Version properties.
using namespace System;
// Create an OperatingSystem object and display the Platform
// and Version properties.
void BuildOSObj( PlatformID pID, Version^ ver )
{
OperatingSystem^ opSys = gcnew OperatingSystem( pID,ver );
PlatformID platform = opSys->Platform;
Version^ version = opSys->Version;
Console::WriteLine( " Platform: {0,-15} Version: {1}", platform, version );
}
void BuildOperatingSystemObjects()
{
// The Version object does not need to correspond to an
// actual OS version.
Version^ verNull = gcnew Version;
Version^ verString = gcnew Version( "3.5.8.13" );
Version^ verMajMin = gcnew Version( 6,10 );
Version^ verMMBld = gcnew Version( 5,25,5025 );
Version^ verMMBVer = gcnew Version( 5,6,7,8 );
// All PlatformID members are shown here.
BuildOSObj( PlatformID::Win32NT, verNull );
BuildOSObj( PlatformID::Win32S, verString );
BuildOSObj( PlatformID::Win32Windows, verMajMin );
BuildOSObj( PlatformID::WinCE, verMMBld );
BuildOSObj( PlatformID::Win32NT, verMMBVer );
}
int main()
{
Console::WriteLine( "This example of OperatingSystem::Platform "
"and OperatingSystem::Version \n"
"generates the following output.\n" );
Console::WriteLine( "Create several OperatingSystem objects "
"and display their properties:\n" );
BuildOperatingSystemObjects();
Console::WriteLine( "\nThe operating system of the host computer is:\n" );
BuildOSObj( Environment::OSVersion->Platform, Environment::OSVersion->Version );
}
/*
This example of OperatingSystem::Platform and OperatingSystem::Version
generates the following output.
Create several OperatingSystem objects and display their properties:
Platform: Win32NT Version: 0.0
Platform: Win32S Version: 3.5.8.13
Platform: Win32Windows Version: 6.10
Platform: WinCE Version: 5.25.5025
Platform: Win32NT Version: 5.6.7.8
The operating system of the host computer is:
Platform: Win32NT Version: 5.1.2600.0
*/
// Example for the OperatingSystem.Platform and
// OperatingSystem.Version properties.
using System;
class PlatformVersionDemo
{
// Create an OperatingSystem object and display the Platform
// and Version properties.
static void BuildOSObj( PlatformID pID, Version ver )
{
OperatingSystem opSys = new OperatingSystem( pID, ver );
PlatformID platform = opSys.Platform;
Version version = opSys.Version;
Console.WriteLine( " Platform: {0,-15} Version: {1}",
platform, version );
}
static void BuildOperatingSystemObjects( )
{
// The Version object does not need to correspond to an
// actual OS version.
Version verNull = new Version( );
Version verString = new Version( "3.5.8.13" );
Version verMajMin = new Version( 6, 10 );
Version verMMBld = new Version( 5, 25, 5025 );
Version verMMBVer = new Version( 5, 6, 7, 8 );
// All PlatformID members are shown here.
BuildOSObj( PlatformID.Win32NT, verNull );
BuildOSObj( PlatformID.Win32S, verString );
BuildOSObj( PlatformID.Win32Windows, verMajMin );
BuildOSObj( PlatformID.WinCE, verMMBld );
BuildOSObj( PlatformID.Win32NT, verMMBVer );
}
static void Main( )
{
Console.WriteLine(
"This example of OperatingSystem.Platform " +
"and OperatingSystem.Version \n" +
"generates the following output.\n" );
Console.WriteLine(
"Create several OperatingSystem objects " +
"and display their properties:\n" );
BuildOperatingSystemObjects( );
Console.WriteLine(
"\nThe operating system of the host computer is:\n" );
BuildOSObj(
Environment.OSVersion.Platform,
Environment.OSVersion.Version );
}
}
/*
This example of OperatingSystem.Platform and OperatingSystem.Version
generates the following output.
Create several OperatingSystem objects and display their properties:
Platform: Win32NT Version: 0.0
Platform: Win32S Version: 3.5.8.13
Platform: Win32Windows Version: 6.10
Platform: WinCE Version: 5.25.5025
Platform: Win32NT Version: 5.6.7.8
The operating system of the host computer is:
Platform: Win32NT Version: 5.1.2600.0
*/
// Example for the OperatingSystem.Platform and
// OperatingSystem.Version properties.
open System
// Create an OperatingSystem object and display the Platform
// and Version properties.
let buildOSObj pID ver =
let opSys = OperatingSystem(pID, ver)
let platform = opSys.Platform
let version = opSys.Version
printfn $" Platform: {platform,-15} Version: {version}"
let buildOperatingSystemObjects () =
// The Version object does not need to correspond to an
// actual OS version.
let verNull = Version()
let verString = Version("3.5.8.13")
let verMajMin = Version(6, 10)
let verMMBld = Version(5, 25, 5025)
let verMMBVer = Version(5, 6, 7, 8)
// All PlatformID members are shown here.
buildOSObj PlatformID.Win32NT verNull
buildOSObj PlatformID.Win32S verString
buildOSObj PlatformID.Win32Windows verMajMin
buildOSObj PlatformID.WinCE verMMBld
buildOSObj PlatformID.Win32NT verMMBVer
printfn "This example of OperatingSystem.Platform and OperatingSystem.Version \ngenerates the following output.\n"
printfn "Create several OperatingSystem objects and display their properties:\n"
buildOperatingSystemObjects ()
printfn "\nThe operating system of the host computer is:\n"
buildOSObj Environment.OSVersion.Platform Environment.OSVersion.Version
// This example of OperatingSystem.Platform and OperatingSystem.Version
// generates the following output.
//
// Create several OperatingSystem objects and display their properties:
//
// Platform: Win32NT Version: 0.0
// Platform: Win32S Version: 3.5.8.13
// Platform: Win32Windows Version: 6.10
// Platform: WinCE Version: 5.25.5025
// Platform: Win32NT Version: 5.6.7.8
//
// The operating system of the host computer is:
//
// Platform: Win32NT Version: 5.1.2600.0
' Example for the OperatingSystem.Platform and
' OperatingSystem.Version properties.
Module PlatformVersionDemo
' Create an OperatingSystem object, and display the Platform
' and Version properties.
Sub BuildOSObj( pID As PlatformID, ver As Version )
Dim opSys As New OperatingSystem( pID, ver )
Dim platform As PlatformID = opSys.Platform
Dim version As Version = opSys.Version
Console.WriteLine( " Platform: {0,-15} Version: {1}", _
platform, version )
End Sub
Sub BuildOperatingSystemObjects( )
' The Version object does not need to correspond to an
' actual OS version.
Dim verNull As New Version( )
Dim verString As New Version( "3.5.8.13" )
Dim verMajMin As New Version( 6, 10 )
Dim verMMBld As New Version( 5, 25, 5025 )
Dim verMMBVer As New Version( 5, 6, 7, 8 )
' All PlatformID members are shown here.
BuildOSObj( PlatformID.Win32NT, verNull )
BuildOSObj( PlatformID.Win32S, verString )
BuildOSObj( PlatformID.Win32Windows, verMajMin )
BuildOSObj( PlatformID.WinCE, verMMBld )
BuildOSObj( PlatformID.Win32NT, verMMBVer )
End Sub
Sub Main( )
Console.WriteLine( _
"This example of OperatingSystem.Platform " & _
"and OperatingSystem.Version " & vbCrLf & _
"generates the following output." & vbCrLf )
Console.WriteLine( _
"Create several OperatingSystem objects " & _
"and display their properties:" & vbCrLf )
BuildOperatingSystemObjects( )
Console.WriteLine(vbCrLf & _
"The operating system of the host computer is: " & _
vbCrLf )
BuildOSObj( _
Environment.OSVersion.Platform, _
Environment.OSVersion.Version )
End Sub
End Module
' This example of OperatingSystem.Platform and OperatingSystem.Version
' generates the following output.
'
' Create several OperatingSystem objects and display their properties:
'
' Platform: Win32NT Version: 0.0
' Platform: Win32S Version: 3.5.8.13
' Platform: Win32Windows Version: 6.10
' Platform: WinCE Version: 5.25.5025
' Platform: Win32NT Version: 5.6.7.8
'
' The operating system of the host computer is:
'
' Platform: Win32NT Version: 5.1.2600.0
Per un elenco di Windows versioni del sistema operativo e dei relativi numeri di versione corrispondenti, vedere Versione del sistema operativo.
Prodotto | Versioni |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 |
.NET Standard | 2.0, 2.1 |