DynamicMethod.DeclaringType プロパティ

定義

メソッドを宣言する型を取得します。動的メソッドの場合は常に null です。

public:
 virtual property Type ^ DeclaringType { Type ^ get(); };
public override Type? DeclaringType { get; }
public override Type DeclaringType { get; }
member this.DeclaringType : Type
Public Overrides ReadOnly Property DeclaringType As Type

プロパティ値

常に null

次のコード例では、動的メソッドの宣言型を表示します。 このコード例は、DynamicMethod クラスのために提供されている大規模な例の一部です。

// Display the declaring type, which is always null for dynamic
// methods.
if (hello->DeclaringType == nullptr)
{
    Console::WriteLine("\r\nDeclaringType is always null for dynamic methods.");
}
else
{
    Console::WriteLine("DeclaringType: {0}", hello->DeclaringType);
}
// Display the declaring type, which is always null for dynamic
// methods.
if (hello.DeclaringType == null)
{
    Console.WriteLine("\r\nDeclaringType is always null for dynamic methods.");
}
else
{
    Console.WriteLine("DeclaringType: {0}", hello.DeclaringType);
}
' Display the declaring type, which is always Nothing for dynamic
' methods.
If hello.DeclaringType Is Nothing Then
    Console.WriteLine(vbCrLf & "DeclaringType is always Nothing for dynamic methods.")
Else
    Console.WriteLine("DeclaringType: {0}", hello.DeclaringType)
End If

注釈

動的メソッドの場合、 null このプロパティは常に を返します。 動的メソッドが型に論理的に関連付けられている場合でも、型によって宣言されません。

適用対象