Export (0) Print
Expand All
0 out of 2 rated this helpful - Rate this topic

Type.GUID Property

Gets the GUID associated with the Type.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

'Declaration
Public MustOverride ReadOnly Property GUID As Guid
'Usage
Dim instance As Type
Dim value As Guid

value = instance.GUID

/** @property */
public abstract Guid get_GUID ()

public abstract function get GUID () : Guid

Property Value

The GUID associated with the Type.

A GUID is associated with a type using the GuidAttribute attribute.

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

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.