Type.GUID プロパティ

定義

Typeに関連付けられている GUID を取得します。

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

プロパティ値

Typeに関連付けられている GUID。

実装

次の例では、パブリック メソッドを使用してクラス MyClass1を作成し、Typeに対応するMyClass1 オブジェクトを作成し、Guid クラスのGUID プロパティを使用してType構造体を取得します。

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

注釈

このプロパティは、 GuidAttribute 属性を使用して型に関連付けられている GUID を返します。 属性を省略すると、GUID が自動的に割り当てられます。

このプロパティによって返される GUID は、通常、型を COM に公開するために使用されます。 これは、型の一意識別子として使用されるものではありません。

適用対象

こちらもご覧ください