Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Type.GUID Property

Gets the GUID associated with the Type.

[Visual Basic]
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;

Property Value

The GUID associated with the Type.

Example

[Visual Basic, C#, C++] The following example creates the class MyClass1 with a public method, creates a Type object corresponding to MyClass1, and gets the Guid object using the GUID property of the Type class.

[Visual Basic] 

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] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Type Class | Type Members | System Namespace | Guid

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft