Partilhar via


MemberInfo.Module Propriedade

Definição

Obtém o módulo no qual o tipo que declara o membro representado pelo MemberInfo atual está definido.

public:
 virtual property System::Reflection::Module ^ Module { System::Reflection::Module ^ get(); };
public virtual System.Reflection.Module Module { get; }
member this.Module : System.Reflection.Module
Public Overridable ReadOnly Property Module As Module

Valor da propriedade

O Module no qual o tipo que declara o membro representado pelo MemberInfo atual está definido.

Exceções

Este método não está implementado.

Exemplos

O exemplo de código a seguir declara uma classe que herda Object e substitui Object.ToString. O exemplo obtém MethodInfo objetos para o método da ToString classe e para o método herdado GetHashCode e exibe os nomes dos módulos nos quais os dois métodos são declarados.

using System;
using System.Reflection;

public class Test
{
    public override string ToString()
    {
        return "An instance of class Test!";
    }
}

public class Example
{
    public static void Main()
    {
        Test t = new Test();
        MethodInfo mi = t.GetType().GetMethod("ToString");
        Console.WriteLine("{0} is defined in {1}", mi.Name, mi.Module.Name);

        mi = t.GetType().GetMethod("GetHashCode");
        Console.WriteLine("{0} is defined in {1}", mi.Name, mi.Module.Name);
    }
}

/* This example produces code similar to the following:

  ToString is defined in source.exe
  GetHashCode is defined in mscorlib.dll
 */
Imports System.Reflection

Public Class Test
    Public Overrides Function ToString() As String
        Return "An instance of class Test!"
    End Function
End Class

Public Class Example
    Public Shared Sub Main()
        Dim t As New Test()
        Dim mi As MethodInfo = t.GetType().GetMethod("ToString")
        Console.WriteLine(mi.Name & " is defined in " & mi.Module.Name)

        mi = t.GetType().GetMethod("GetHashCode")
        Console.WriteLine(mi.Name & " is defined in " & mi.Module.Name)
    End Sub
End Class

' This example produces code similar to the following:
'
'ToString is defined in source.exe
'GetHashCode is defined in mscorlib.dll

Comentários

Essa propriedade é fornecida como uma conveniência. É equivalente a usar a DeclaringType propriedade para obter o tipo no qual o método é declarado e, em seguida, chamar a Module propriedade do objeto resultante Type .

Aplica-se a

Confira também