Type.GUID-Eigenschaft
Ruft die Type zugeordnete GUID ab.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public MustOverride ReadOnly Property GUID As Guid
'Usage
Dim instance As Type
Dim value As Guid
value = instance.GUID
public abstract Guid GUID { get; }
public:
virtual property Guid GUID {
Guid get () abstract;
}
/** @property */
public abstract Guid get_GUID ()
public abstract function get GUID () : Guid
Eigenschaftenwert
Die Type zugeordnete GUID.
Hinweise
Einem Typ wird eine GUID mit dem GuidAttribute-Attribut zugeordnet.
Beispiel
Im folgenden Beispiel werden die MyClass1
-Klasse mit einer öffentlichen Methode und ein Type-Objekt zu MyClass1
erstellt. Außerdem wird die Guid-Struktur mithilfe der GUID-Eigenschaft der Type-Klasse abgerufen.
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
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0