Type.GUID Propriedade
Definição
public:
abstract property Guid GUID { Guid get(); };
public abstract Guid GUID { get; }
member this.GUID : Guid
Public MustOverride ReadOnly Property GUID As Guid
Valor da propriedade
O GUID associado ao Type.The GUID associated with the Type.
Implementações
Exemplos
O exemplo a seguir cria a classe MyClass1 com um método público, cria um Type objeto correspondente a MyClass1 e obtém a Guid estrutura usando a GUID propriedade da Type classe.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.
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 );
}
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);
}
}
Class MyGetTypeFromCLSID
Public Class MyClass1
Public Sub MyMethod1()
End Sub
End Class
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 = myType.GUID
Console.WriteLine(("The name of the class is " + myType.ToString()))
Console.WriteLine(("The ClassId of MyClass is " + myType.GUID.ToString()))
End Sub
End Class
Comentários
Um GUID é associado a um tipo usando o GuidAttribute atributo.A GUID is associated with a type using the GuidAttribute attribute.