Gets the GUID associated with the Type.
Assembly: mscorlib (in mscorlib.dll)
Syntax . . :: . GUID
Public MustOverride ReadOnly Property GUID As Guidpublic abstract Guid GUID { get; }public:
virtual property Guid GUID {
Guid get () abstract;
}abstract GUID : Guid
Implements
_Type Remarks
A GUID is associated with a type using the GuidAttribute attribute.
Examples
The following example creates the class MyClass1 with a public method, creates a Type object corresponding to MyClass1, and gets the Guid structure using the GUID property of the Type class.
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 );
}
Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.