OperatingSystem Clase
Definición
Representa información acerca de un sistema operativo, como el número de la versión y el identificador de plataforma.Represents information about an operating system, such as the version and platform identifier. Esta clase no puede heredarse.This class cannot be inherited.
public ref class OperatingSystem sealed : ICloneable, System::Runtime::Serialization::ISerializable
public ref class OperatingSystem sealed : ICloneable
public sealed class OperatingSystem : 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
type OperatingSystem = class
interface ICloneable
interface ISerializable
[<System.Serializable>]
type OperatingSystem = class
interface ICloneable
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type OperatingSystem = class
interface ICloneable
interface ISerializable
Public NotInheritable Class OperatingSystem
Implements ICloneable, ISerializable
Public NotInheritable Class OperatingSystem
Implements ICloneable
- Herencia
-
OperatingSystem
- Atributos
- Implementaciones
Ejemplos
En el ejemplo de código siguiente OperatingSystem se usa el objeto para mostrar información sobre el sistema operativo en tiempo de ejecución.The following code example uses the OperatingSystem object to display information about the runtime operating system.
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'
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.The OperatingSystem class contains information about an operating system.
Para obtener información sobre el sistema operativo en tiempo de ejecución actual, recupere el OperatingSystem objeto devuelto por la Environment.OSVersion propiedad.For information about the current runtime operating system, retrieve the OperatingSystem object returned by the Environment.OSVersion property. Para obtener una lista de las versiones del sistema operativo Windows y sus números de versión correspondientes devueltos por las Version VersionString propiedades y y el ToString método, consulte versión del sistema operativo.For a list of Windows operating system versions and their corresponding version numbers returned by the Version and VersionString properties and the ToString method, see Operating System Version.
Por diseño, la OperatingSystem clase no es una finalidad general de describir un sistema operativo y no se puede derivar un tipo más inclusivo de la OperatingSystem clase.By design, the OperatingSystem class is not a general purpose means of describing an operating system, and you cannot derive a more inclusive type from the OperatingSystem class. Si necesita un tipo que contenga otra información acerca de un sistema operativo, cree su propio tipo y, a continuación, incluya un campo de tipo OperatingSystem y los campos, propiedades o métodos adicionales que necesite.If you need a type to contain other information about an operating system, create your own type, then include a field of type OperatingSystem and any additional fields, properties, or methods that you require.
Constructores
| OperatingSystem(PlatformID, Version) |
Inicializa una nueva instancia de la clase OperatingSystem con el valor del identificador de plataforma y el objeto de versión especificados.Initializes a new instance of the OperatingSystem class, using the specified platform identifier value and version object. |
Propiedades
| Platform |
Obtiene un valor de la enumeración PlatformID que identifica la plataforma del sistema operativo.Gets a PlatformID enumeration value that identifies the operating system platform. |
| ServicePack |
Obtiene la versión del Service Pack representada por este objeto OperatingSystem.Gets the service pack version represented by this OperatingSystem object. |
| Version |
Obtiene un objeto Version que identifica el sistema operativo.Gets a Version object that identifies the operating system. |
| VersionString |
Obtiene la representación de cadena concatenada del identificador de la plataforma, versión y Service Pack instalados actualmente en el sistema operativo.Gets the concatenated string representation of the platform identifier, version, and service pack that are currently installed on the operating system. |
Métodos
| Clone() |
Crea un objeto OperatingSystem idéntico a esta instancia.Creates an OperatingSystem object that is identical to this instance. |
| Equals(Object) |
Determina si el objeto especificado es igual que el objeto actual.Determines whether the specified object is equal to the current object. (Heredado de Object) |
| GetHashCode() |
Sirve como la función hash predeterminada.Serves as the default hash function. (Heredado de Object) |
| GetObjectData(SerializationInfo, StreamingContext) |
Rellena un objeto SerializationInfo con todos los datos necesarios para deserializar esta instancia.Populates a SerializationInfo object with the data necessary to deserialize this instance. |
| GetType() |
Obtiene el Type de la instancia actual.Gets the Type of the current instance. (Heredado de Object) |
| IsAndroid() |
Indica si la aplicación actual se está ejecutando en Android o no.Indicates whether the current application is running on Android. |
| IsAndroidVersionAtLeast(Int32, Int32, Int32, Int32) |
Comprueba si la versión de Android (devuelta por el comando de LinuxChecks if the Android version (returned by the Linux command |
| IsBrowser() |
Indica si la aplicación actual se está ejecutando como WASM en un explorador.Indicates whether the current application is running as WASM in a browser. |
| IsFreeBSD() |
Indica si la aplicación actual se está ejecutando en FreeBSD o no.Indicates whether the current application is running on FreeBSD. |
| IsFreeBSDVersionAtLeast(Int32, Int32, Int32, Int32) |
Comprueba si la versión de FreeBSD (devuelta por el comando de LinuxChecks if the FreeBSD version (returned by the Linux command |
| IsIOS() |
Indica si la aplicación actual se está ejecutando en iOS o no.Indicates whether the current application is running on iOS. |
| IsIOSVersionAtLeast(Int32, Int32, Int32) |
Comprueba si la versión de iOS (devuelta porChecks if the iOS version (returned by |
| IsLinux() |
Indica si la aplicación actual se está ejecutando en Linux o no.Indicates whether the current application is running on Linux. |
| IsMacOS() |
Indica si la aplicación actual se está ejecutando en macOS o no.Indicates whether the current application is running on macOS. |
| IsMacOSVersionAtLeast(Int32, Int32, Int32) |
Comprueba si la versión de macOS (devuelta porChecks if the macOS version (returned by |
| IsOSPlatform(String) |
Indica si la aplicación actual se está ejecutando en la plataforma especificada o no.Indicates whether the current application is running on the specified platform. |
| IsOSPlatformVersionAtLeast(String, Int32, Int32, Int32, Int32) |
Comprueba si la versión del sistema operativo es mayor o igual que la versión de plataforma especificada.Checks if the operating system version is greater than or equal to the specified platform version. Este método se puede usar para proteger las API que se agregaron en la versión de sistema operativo especificada.This method can be used to guard APIs that were added in the specified OS version. |
| IsTvOS() |
Indica si la aplicación actual se está ejecutando en tvOS o no.Indicates whether the current application is running on tvOS. |
| IsTvOSVersionAtLeast(Int32, Int32, Int32) |
Comprueba si la versión de tvOS (devuelta porChecks if the tvOS version (returned by |
| IsWatchOS() |
Indica si la aplicación actual se está ejecutando en watchOS o no.Indicates whether the current application is running on watchOS. |
| IsWatchOSVersionAtLeast(Int32, Int32, Int32) |
Comprueba si la versión de watchOS (devuelta porChecks if the watchOS version (returned by |
| IsWindows() |
Indica si la aplicación actual se está ejecutando en Windows o no.Indicates whether the current application is running on Windows. |
| IsWindowsVersionAtLeast(Int32, Int32, Int32, Int32) |
Comprueba si la versión de Windows (devuelta porChecks if the Windows version (returned by |
| MemberwiseClone() |
Crea una copia superficial del Object actual.Creates a shallow copy of the current Object. (Heredado de Object) |
| ToString() |
Convierte el valor de este objeto OperatingSystem en su representación de cadena equivalente.Converts the value of this OperatingSystem object to its equivalent string representation. |