Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​OperatingSystem

Assembly: System.Runtime

Inheritance: object → OperatingSystem

Implemented Interfaces

Represents information about an operating system, such as the version and platform identifier. This class cannot be inherited.

Properties

public PlatformID
Platform
Gets a <see cref="T:System.PlatformID" /> enumeration value that identifies the operating system platform.
public string
ServicePack
Gets the service pack version represented by this <see cref="T:System.OperatingSystem" /> object.
public Version
Version
Gets a <see cref="T:System.Version" /> object that identifies the operating system.
public string
VersionString
Gets the concatenated string representation of the platform identifier, version, and service pack that are currently installed on the operating system.

Methods

public object
Clone​()
Creates an <see cref="T:System.OperatingSystem" /> object that is identical to this instance.
Returns An <see cref="T:System.OperatingSystem" /> object that is a copy of this instance.
public void
GetObjectData​(SerializationInfo info, StreamingContext context)
Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo" /> object with the data necessary to deserialize this instance.
info The object to populate with serialization information.
context The place to store and retrieve serialized data. Reserved for future use.
public static bool
IsAndroid​()
Indicates whether the current application is running on Android.
Returns <see langword="true" /> if the current application is running on Android; <see langword="false" /> otherwise.
public static bool
IsAndroidVersionAtLeast​(int major, int minor = 0, int build = 0, int revision = 0)
Checks if the Android version (returned by the Linux command <c>uname</c> ) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version.
Returns <see langword="true" /> if the current application is running on an Android version that is at least what was specified in the parameters; <see langword="false" /> otherwise.
major The major release number.
minor The minor release number.
build The build release number.
revision The revision release number.
public static bool
IsBrowser​()
Indicates whether the current application is running as WASM in a browser.
Returns <see langword="true" /> if the current application is running as WASM in a browser; <see langword="false" /> otherwise.
public static bool
IsFreeBSD​()
Indicates whether the current application is running on FreeBSD.
Returns <see langword="true" /> if the current application is running on FreeBSD; <see langword="false" /> otherwise.
public static bool
IsFreeBSDVersionAtLeast​(int major, int minor = 0, int build = 0, int revision = 0)
Checks if the FreeBSD version (returned by the Linux command <c>uname</c> ) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified version.
Returns <see langword="true" /> if the current application is running on a FreeBSD version that is at least what was specified in the parameters; <see langword="false" /> otherwise.
major The major release number.
minor The minor release number.
build The build release number.
revision The revision release number.
public static bool
IsIOS​()
Indicates whether the current application is running on iOS or MacCatalyst.
Returns <see langword="true" /> if the current application is running on iOS or MacCatalyst; <see langword="false" /> otherwise.
public static bool
IsIOSVersionAtLeast​(int major, int minor = 0, int build = 0)
Checks if the iOS/MacCatalyst version (returned by <c>libobjc.get_operatingSystemVersion</c> ) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified iOS version.
Returns <see langword="true" /> if the current application is running on an iOS/MacCatalyst version that is at least what was specified in the parameters; <see langword="false" /> otherwise.
major The major release number.
minor The minor release number.
build The build release number.
public static bool
IsLinux​()
Indicates whether the current application is running on Linux.
Returns <see langword="true" /> if the current application is running on Linux; <see langword="false" /> otherwise.
public static bool
IsMacCatalyst​()
Indicates whether the current application is running on Mac Catalyst.
Returns <see langword="true" /> if the current application is running on Mac Catalyst; <see langword="false" /> otherwise.
public static bool
IsMacCatalystVersionAtLeast​(int major, int minor = 0, int build = 0)
Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a ≤ version comparison. Used to guard APIs that were added in the given Mac Catalyst release.
Returns <see langword="true" /> if the Mac Catalyst version is greater or equal than the specified version comparison; <see langword="false" /> otherwise.
major The version major number.
minor The version minor number.
build The version build number.
public static bool
IsMacOS​()
Indicates whether the current application is running on macOS.
Returns <see langword="true" /> if the current application is running on macOS; <see langword="false" /> otherwise.
public static bool
IsMacOSVersionAtLeast​(int major, int minor = 0, int build = 0)
Checks if the macOS version (returned by <c>libobjc.get_operatingSystemVersion</c> ) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified macOS version.
Returns <see langword="true" /> if the current application is running on an macOS version that is at least what was specified in the parameters; <see langword="false" /> otherwise.
major The major release number.
minor The minor release number.
build The build release number.
public static bool
IsOSPlatform​(string platform)
Indicates whether the current application is running on the specified platform.
Returns <see langword="true" /> if the current application is running on the specified platform; <see langword="false" /> otherwise.
platform The case-insensitive platform name. Examples: Browser, Linux, FreeBSD, Android, iOS, macOS, tvOS, watchOS, Windows.
public static bool
IsOSPlatformVersionAtLeast​(string platform, int major, int minor = 0, int build = 0, int revision = 0)
Checks if the operating system version is greater than or equal to the specified platform version. This method can be used to guard APIs that were added in the specified OS version.
Returns <see langword="true" /> if the current application is running on the specified platform and is at least in the version specified in the parameters; <see langword="false" /> otherwise.
platform The case-insensitive platform name. Examples: Browser, Linux, FreeBSD, Android, iOS, macOS, tvOS, watchOS, Windows.
major The major release number.
minor The minor release number (optional).
build The build release number (optional).
revision The revision release number (optional).
public static bool
IsTvOS​()
Indicates whether the current application is running on tvOS.
Returns <see langword="true" /> if the current application is running on tvOS; <see langword="false" /> otherwise.
public static bool
IsTvOSVersionAtLeast​(int major, int minor = 0, int build = 0)
Checks if the tvOS version (returned by <c>libobjc.get_operatingSystemVersion</c> ) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified tvOS version.
Returns <see langword="true" /> if the current application is running on a tvOS version that is at least what was specified in the parameters; <see langword="false" /> otherwise.
major The major release number.
minor The minor release number.
build The build release number.
public static bool
IsWasi​()
Indicates whether the current application is running as WASI.
public static bool
IsWatchOS​()
Indicates whether the current application is running on watchOS.
Returns <see langword="true" /> if the current application is running on watchOS; <see langword="false" /> otherwise.
public static bool
IsWatchOSVersionAtLeast​(int major, int minor = 0, int build = 0)
Checks if the watchOS version (returned by <c>libobjc.get_operatingSystemVersion</c> ) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified watchOS version.
Returns <see langword="true" /> if the current application is running on a watchOS version that is at least what was specified in the parameters; <see langword="false" /> otherwise.
major The major release number.
minor The minor release number.
build The build release number.
public static bool
IsWindows​()
Indicates whether the current application is running on Windows.
Returns <see langword="true" /> if the current application is running on Windows; <see langword="false" /> otherwise.
public static bool
IsWindowsVersionAtLeast​(int major, int minor = 0, int build = 0, int revision = 0)
Checks if the Windows version (returned by <c>RtlGetVersion</c> ) is greater than or equal to the specified version. This method can be used to guard APIs that were added in the specified Windows version.
Returns <see langword="true" /> if the current application is running on a Windows version that is at least what was specified in the parameters; <see langword="false" /> otherwise.
major The major release number.
minor The minor release number.
build The build release number.
revision The revision release number.
public string
ToString​()
Converts the value of this <see cref="T:System.OperatingSystem" /> object to its equivalent string representation.
Returns The string representation of the values returned by the <see cref="P:System.OperatingSystem.Platform" /> , <see cref="P:System.OperatingSystem.Version" /> , and <see cref="P:System.OperatingSystem.ServicePack" /> properties.
public bool
Equals​(object obj)
Inherited from object
Determines whether the specified object is equal to the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
obj The object to compare with the current object.
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public int
GetHashCode​()
Inherited from object
Serves as the default hash function.
Returns A hash code for the current object.
public Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .