DynamicMethod.DeclaringType Propriedade

Definição

Obtém o tipo que declara o método, que é sempre null para métodos dinâmicos.

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

Valor da propriedade

Type

Sempre null.

Exemplos

O exemplo de código a seguir exibe o tipo de declaração de um método dinâmico. Este exemplo de código faz parte de um exemplo maior fornecido para a DynamicMethod classe.

// 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

Comentários

Essa propriedade sempre retorna null para métodos dinâmicos. Mesmo quando um método dinâmico está logicamente associado a um tipo, ele não é declarado pelo tipo.

Aplica-se a