Type.GUID プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)



パブリック メソッドを持つクラス 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
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); } }
using namespace System; ref class MyGetTypeFromCLSID { public: ref class MyClass1 { public: void MyMethod1(){} }; }; int main() { // Get the type corresponding to the class MyClass. Type^ myType = MyGetTypeFromCLSID::MyClass1::typeid; // Get the Object* of the Guid. Guid myGuid = (Guid)myType->GUID; Console::WriteLine( "The name of the class is {0}", myType ); Console::WriteLine( "The ClassId of MyClass is {0}", myType->GUID ); }
import System.*; class MyGetTypeFromCLSID { public class MyClass1 { public void MyMethod1() { } //MyMethod1 } //MyClass1 public static void main(String[] args) { // Get the type corresponding to the class MyClass. Type myType = MyClass1.class.ToType(); // Get the object of the Guid. Guid myGuid = (Guid)(myType.get_GUID()); Console.WriteLine("The name of the class is " + myType.ToString()); Console.WriteLine("The ClassId of MyClass is " + myType.get_GUID()); } //main } //MyGetTypeFromCLSID

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


_Type.GUID プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)



Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- Type.GUID プロパティのページへのリンク