Auf Englisch lesen Bearbeiten

Freigeben über


PlatformID Enum

Definition

Identifies the operating system, or platform, supported by an assembly.

C#
public enum PlatformID
C#
[System.Serializable]
public enum PlatformID
C#
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum PlatformID
Inheritance
PlatformID
Attributes

Fields

Name Value Description
Win32S 0

The operating system is Win32s. This value is no longer in use.

Win32Windows 1

The operating system is Windows 95 or Windows 98. This value is no longer in use.

Win32NT 2

The operating system is Windows NT or later.

WinCE 3

The operating system is Windows CE. This value is no longer in use.

Unix 4

The operating system is Unix.

Xbox 5

The development platform is Xbox 360. This value is no longer in use.

MacOSX 6

The operating system is Macintosh. This value was returned by Silverlight. On .NET Core, its replacement is Unix.

Other 7

Any other operating system. This includes Browser (WASM).

Examples

The following example demonstrates using the PlatformID class to identify the currently executing operating system:

C#
// This example demonstrates the PlatformID enumeration.
using System;

class Sample
{
    public static void Main()
    {
    string msg1 = "This is a Windows operating system.";
    string msg2 = "This is a Unix operating system.";
    string msg3 = "ERROR: This platform identifier is invalid.";

// Assume this example is run on a Windows operating system.

    OperatingSystem os = Environment.OSVersion;
    PlatformID     pid = os.Platform;
    switch (pid)
        {
        case PlatformID.Win32NT:
        case PlatformID.Win32S:
        case PlatformID.Win32Windows:
        case PlatformID.WinCE:
            Console.WriteLine(msg1);
            break;
        case PlatformID.Unix:
            Console.WriteLine(msg2);
            break;
        default:
            Console.WriteLine(msg3);
            break;
        }
    }
}
/*
This example produces the following results:

This is a Windows operating system.
*/

Remarks

Use the Environment.OSVersion and OperatingSystem.Platform properties to obtain the PlatformID enumeration for the currently executing operating system or development platform. Use the PlatformID enumeration to help determine whether the current operating system or development platform supports your application.

You can use the underlying integer value of each PlatformID enumeration member as the PlatformId argument for the SignTool.exe (Sign Tool) utility.

Applies to

Produkt Versionen
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.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, 4.8.1
.NET Standard 2.0, 2.1