OperatingSystem Clase
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Representa información sobre un sistema operativo, como la versión y el identificador de la plataforma. Esta clase no puede heredarse.
public ref class OperatingSystem sealed : ICloneable
public ref class OperatingSystem sealed : ICloneable, System::Runtime::Serialization::ISerializable
[System.Serializable]
public sealed class OperatingSystem : ICloneable
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class OperatingSystem : ICloneable, System.Runtime.Serialization.ISerializable
public sealed class OperatingSystem : ICloneable, System.Runtime.Serialization.ISerializable
[<System.Serializable>]
type OperatingSystem = class
interface ICloneable
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type OperatingSystem = class
interface ICloneable
interface ISerializable
type OperatingSystem = class
interface ICloneable
interface ISerializable
Public NotInheritable Class OperatingSystem
Implements ICloneable
Public NotInheritable Class OperatingSystem
Implements ICloneable, ISerializable
- Herencia
-
OperatingSystem
- Atributos
- Implementaciones
Ejemplos
En el ejemplo de código siguiente se usa el OperatingSystem objeto para mostrar información sobre el sistema operativo en tiempo de ejecución.
using System;
public class Example
{
public static void Main()
{
var os = Environment.OSVersion;
Console.WriteLine("Current OS Information:\n");
Console.WriteLine("Platform: {0:G}", os.Platform);
Console.WriteLine("Version String: {0}", os.VersionString);
Console.WriteLine("Version Information:");
Console.WriteLine(" Major: {0}", os.Version.Major);
Console.WriteLine(" Minor: {0}", os.Version.Minor);
Console.WriteLine("Service Pack: '{0}'", os.ServicePack);
}
}
// If run on a Windows 8.1 system, the example displays output like the following:
// Current OS Information:
//
// Platform: Win32NT
// Version String: Microsoft Windows NT 6.2.9200.0
// Version Information:
// Major: 6
// Minor: 2
// Service Pack: ''
// If run on a Windows 7 system, the example displays output like the following:
// Current OS Information:
//
// Platform: Win32NT
// Version String: Microsoft Windows NT 6.1.7601 Service Pack 1
// Version Information:
// Major: 6
// Minor: 1
// Service Pack: 'Service Pack 1'
open System
let os = Environment.OSVersion
printfn "Current OS Information:\n"
printfn $"Platform: {os.Platform:G}"
printfn $"Version String: {os.VersionString}"
printfn $"Version Information:"
printfn $" Major: {os.Version.Major}"
printfn $" Minor: {os.Version.Minor}"
printfn $"Service Pack: '{os.ServicePack}'"
// If run on a Windows 8.1 system, the example displays output like the following:
// Current OS Information:
//
// Platform: Win32NT
// Version String: Microsoft Windows NT 6.2.9200.0
// Version Information:
// Major: 6
// Minor: 2
// Service Pack: ''
// If run on a Windows 7 system, the example displays output like the following:
// Current OS Information:
//
// Platform: Win32NT
// Version String: Microsoft Windows NT 6.1.7601 Service Pack 1
// Version Information:
// Major: 6
// Minor: 1
// Service Pack: 'Service Pack 1'
Module Example
Public Sub Main()
Dim os As OperatingSystem = Environment.OSVersion
Console.WriteLine("Current OS Information:")
Console.WriteLine()
Console.WriteLine("Platform: {0:G}", os.Platform)
Console.WriteLine("Version String: {0}", os.VersionString)
Console.WriteLine("Version Information:")
Console.WriteLine(" Major: {0}", os.Version.Major)
Console.WriteLine(" Minor: {0}", os.Version.Minor)
Console.WriteLine("Service Pack: '{0}'", os.ServicePack)
End Sub
End Module
' If run on a Windows 8.1 system, the example displays output like the following:
' Current OS Information:
'
' Platform: Win32NT
' Version String: Microsoft Windows NT 6.2.9200.0
' Version Information:
' Major: 6
' Minor: 2
' Service Pack: ''
' If run on a Windows 7 system, the example displays output like the following:
' Current OS Information:
'
' Platform: Win32NT
' Version String: Microsoft Windows NT 6.1.7601 Service Pack 1
' Version Information:
' Major: 6
' Minor: 1
' Service Pack: 'Service Pack 1'
Comentarios
La OperatingSystem clase contiene información sobre un sistema operativo.
Para obtener información sobre el sistema operativo en tiempo de ejecución actual, recupere el OperatingSystem objeto devuelto por la Environment.OSVersion propiedad . Para obtener una lista de las versiones del sistema operativo Windows y sus números de versión correspondientes devueltos por las Version propiedades y VersionString y el ToString método, vea Versión del sistema operativo.
Por diseño, la OperatingSystem clase no es un medio de uso general para describir un sistema operativo y no puede derivar un tipo más inclusivo de la OperatingSystem clase. Si necesita un tipo para contener otra información sobre un sistema operativo, cree su propio tipo, incluya un campo de tipo OperatingSystem y los campos, propiedades o métodos adicionales que necesite.
Constructores
| Nombre | Description |
|---|---|
| OperatingSystem(PlatformID, Version) |
Inicializa una nueva instancia de la OperatingSystem clase utilizando el valor de identificador de plataforma y el objeto de versión especificados. |
Propiedades
| Nombre | Description |
|---|---|
| Platform |
Obtiene un PlatformID valor de enumeración que identifica la plataforma del sistema operativo. |
| ServicePack |
Obtiene la versión del Service Pack representada por este OperatingSystem objeto. |
| Version |
Obtiene un Version objeto que identifica el sistema operativo. |
| VersionString |
Obtiene la representación de cadena concatenada del identificador, la versión y el Service Pack de plataforma que están instalados actualmente en el sistema operativo. |
Métodos
| Nombre | Description |
|---|---|
| Clone() |
Crea un OperatingSystem objeto idéntico a esta instancia. |
| Equals(Object) |
Determina si el objeto especificado es igual al objeto actual. (Heredado de Object) |
| GetHashCode() |
Actúa como la función hash predeterminada. (Heredado de Object) |
| GetObjectData(SerializationInfo, StreamingContext) |
Rellena un SerializationInfo objeto con los datos necesarios para deserializar esta instancia. |
| GetType() |
Obtiene el Type de la instancia actual. (Heredado de Object) |
| MemberwiseClone() |
Crea una copia superficial del Objectactual. (Heredado de Object) |
| ToString() |
Convierte el valor de este OperatingSystem objeto en su representación de cadena equivalente. |