Type.GUID Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
ile ilişkili GUID'yi Typealır.
public:
abstract property Guid GUID { Guid get(); };
public abstract Guid GUID { get; }
member this.GUID : Guid
Public MustOverride ReadOnly Property GUID As Guid
Özellik Değeri
ile Typeilişkili GUID.
Uygulamalar
Örnekler
Aşağıdaki örnek sınıfını MyClass1 ortak bir yöntemle oluşturur, öğesine Typekarşılık gelen bir MyClass1 nesne oluşturur ve sınıfın Guid özelliğini kullanarak yapıyı GUID alırType.
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);
}
}
type MyClass1() =
member _.MyMethod1() = ()
// Get the type corresponding to the class MyClass.
let myType = typeof<MyClass1>
// Get the object of the Guid.
let myGuid = myType.GUID
printfn $"The name of the class is {myType}"
printfn $"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
Açıklamalar
Bu özellik özniteliğini kullanan GuidAttribute bir türle ilişkilendirilmiş bir GUID döndürür. Öznitelik atlanırsa, otomatik olarak bir GUID atanır.
Bu özellik tarafından döndürülen GUID genellikle COM'a bir tür göstermek için kullanılır. Türün benzersiz tanımlayıcısı olarak kullanılması amaçlanmamıştır.