Share via


Type.GUID プロパティ

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

Public MustOverride ReadOnly Property GUID As Guid
[C#]
public abstract Guid GUID {get;}
[C++]
public: __property virtual Guid get_GUID() = 0;
[JScript]
public abstract function get GUID() : Guid;

プロパティ値

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

使用例

[Visual Basic, C#, C++] パブリック メソッドを持つクラス MyClass1 を作成し、 MyClass1 に対応する Type オブジェクトを作成して、 Type クラスの GUID プロパティを使用して Guid オブジェクトを取得する例を次に示します。

 

Imports System

Class MyGetTypeFromCLSID

    Public Class MyClass1

        Public Sub MyMethod1()
        End Sub 'MyMethod1

    End Class 'MyClass1

    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 = CType(myType.GUID, Guid)
        Console.WriteLine(("The name of the class is " + myType.ToString()))
        Console.WriteLine(("The ClassId of MyClass is " + myType.GUID.ToString()))
    End Sub 'Main 
End Class 'MyGetTypeFromCLSID

[C#] 
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);                
    }
}

[C++] 
#using <mscorlib.dll>

using namespace System;

__gc class MyGetTypeFromCLSID {
public:
   __gc class MyClass1 {
   public:
      void MyMethod1() {
      }
   };
};

int main() {
   // Get the type corresponding to the class MyClass.
   Type*  myType = __typeof(MyGetTypeFromCLSID::MyClass1);
   // Get the Object* of the Guid.
   Guid myGuid =(Guid) myType->GUID;
   Console::WriteLine(S"The name of the class is {0}", myType);
   Console::WriteLine(S"The ClassId of MyClass is {0}",__box( myType->GUID));
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

Type クラス | Type メンバ | System 名前空間 | Guid