Type.GUID Eigenschaft

Definition

Ruft die GUID ab, die der Type.

public:
 abstract property Guid GUID { Guid get(); };
public abstract Guid GUID { get; }
member this.GUID : Guid
Public MustOverride ReadOnly Property GUID As Guid

Eigenschaftswert

Die GUID, die der Type.

Implementiert

Beispiele

Im folgenden Beispiel wird die Klasse MyClass1 mit einer öffentlichen Methode erstellt, ein Type Objekt erstellt, das dem entspricht MyClass1, und ruft die Guid Struktur mithilfe GUID der Eigenschaft der Type Klasse ab.

using System;

class MyGetTypeFromCLSID
{
    public class MyClass1
    {
        public void MyMethod1()
        {
        }
    }
    public static void Main()
    {
        // Get the type corresponding to the class MyClass.
        Type myType = typeof(MyClass1);
        // Get the object of the Guid.
        Guid myGuid =(Guid) myType.GUID;
        Console.WriteLine("The name of the class is "+myType.ToString());
        Console.WriteLine("The ClassId of MyClass is "+myType.GUID);				
    }
}
type MyClass1() =
    member _.MyMethod1() = ()

// Get the type corresponding to the class MyClass.
let myType = typeof<MyClass1>
// Get the object of the Guid.
let myGuid = myType.GUID
printfn $"The name of the class is {myType}"
printfn $"The ClassId of MyClass is {myType.GUID}"
Class MyGetTypeFromCLSID

    Public Class MyClass1

        Public Sub MyMethod1()
        End Sub

    End Class

    Public Shared Sub Main()
        ' Get the type corresponding to the class MyClass.
        Dim myType As Type = GetType(MyClass1)
        ' Get the object of the Guid.
        Dim myGuid As Guid = myType.GUID
        Console.WriteLine(("The name of the class is " + myType.ToString()))
        Console.WriteLine(("The ClassId of MyClass is " + myType.GUID.ToString()))
    End Sub
End Class

Hinweise

Diese Eigenschaft gibt eine GUID zurück, die einem Typ mithilfe des GuidAttribute Attributs zugeordnet ist. Wenn das Attribut nicht angegeben wird, wird automatisch eine GUID zugewiesen.

Die von dieser Eigenschaft zurückgegebene GUID wird in der Regel verwendet, um einen Typ für COM verfügbar zu machen. Es soll nicht als eindeutiger Bezeichner des Typs verwendet werden.

Gilt für:

Weitere Informationen