Type.GUID プロパティ
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
Typeに関連付けられている GUID を取得します。
public:
abstract property Guid GUID { Guid get(); };
C#
public abstract Guid GUID { get; }
member this.GUID : Guid
Public MustOverride ReadOnly Property GUID As Guid
Type に関連付けられている GUID。
次の例では、パブリック メソッドを使用して クラスMyClass1
を作成し、 に対応する オブジェクトをMyClass1
作成Type
し、 クラスの プロパティをGuidGUID
使用して構造体をType
取得します。
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 );
}
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);
}
}
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
このプロパティは、 属性を使用して型に関連付けられている GUID を GuidAttribute 返します。 属性を省略すると、GUID が自動的に割り当てられます。
このプロパティによって返される GUID は、通常、COM に型を公開するために使用されます。 型の一意識別子として使用するためのものではありません。
製品 | バージョン |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。