MemberInfo.Module MemberInfo.Module MemberInfo.Module MemberInfo.Module Property

Definition

Ruft das Modul ab, in dem der Typ definiert ist, der den von der aktuellen MemberInfo-Klasse dargestellten Member deklariert.Gets the module in which the type that declares the member represented by the current MemberInfo is defined.

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

Eigenschaftswert

Die Module-Klasse, in der der Typ definiert ist, der den von der aktuellen MemberInfo-Klasse dargestellten Member deklariert.The Module in which the type that declares the member represented by the current MemberInfo is defined.

Ausnahmen

Diese Methode ist nicht implementiert.This method is not implemented.

Beispiele

Im folgenden Codebeispiel deklariert eine Klasse, die erbt Object und überschreibt Object.ToString.The following code example declares a class that inherits Object and overrides Object.ToString. Im Beispiel MethodInfo Objekte für der Klasse des ToString Methode und für die geerbte GetHashCode -Methode, und zeigt die Namen der Module in der die beiden Methoden deklariert werden.The example obtains MethodInfo objects for the class's ToString method and for the inherited GetHashCode method, and displays the names of the modules in which the two methods are declared.

using namespace System;
using namespace System::Reflection;

public ref class Test
{
public:
    virtual String^ ToString() override
    {
        return "An instance of class Test!";
    }
};

int main()
{
    Test^ target = gcnew Test();
    MethodInfo^ toStringInfo = target->GetType()->GetMethod("ToString");
    Console::WriteLine("{0} is defined in {1}", toStringInfo->Name,
        toStringInfo->Module->Name);

    MethodInfo^ getHashCodeInfo = target->GetType()->GetMethod("GetHashCode");
    Console::WriteLine("{0} is defined in {1}", getHashCodeInfo->Name,
        getHashCodeInfo->Module->Name);
}

/*
* This example produces the following console output:
*
* ToString is defined in source.exe
* GetHashCode is defined in mscorlib.dll
*/
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
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

Hinweise

Diese Eigenschaft ist zur Vereinfachung bereitgestellt.This property is provided as a convenience. Es ist äquivalent zur Verwendung der DeclaringType -Eigenschaft zum Abrufen des Typs, in dem die Methode deklariert ist, und zum Aufrufen der Module -Eigenschaft des resultierenden Type Objekt.It is equivalent to using the DeclaringType property to get the type in which the method is declared, and then calling the Module property of the resulting Type object.

Gilt für:

Siehe auch