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

정의

현재 MemberInfo가 나타내는 멤버를 선언하는 형식이 정의된 모듈을 가져옵니다.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

속성 값

현재 Module가 나타내는 멤버를 선언하는 형식이 정의된 MemberInfo입니다.The Module in which the type that declares the member represented by the current MemberInfo is defined.

예외

이 메서드가 구현되지 않은 경우This method is not implemented.

예제

다음 코드 예제에서는 상속 되는 클래스 선언 Object 재정의 및 Object.ToString합니다.The following code example declares a class that inherits Object and overrides Object.ToString. 예제를 가져옵니다 MethodInfo 클래스의 개체가 ToString 메서드 및 상속 된 GetHashCode 메서드를 두 메서드 선언 되는 모듈의 이름을 표시 합니다.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

설명

이 속성은 편의 위해 제공 됩니다.This property is provided as a convenience. 사용 하는 것과 같습니다 합니다 DeclaringType 메서드 선언 되는 형식을 가져올 속성을 호출 합니다 Module 결과 속성 Type 개체입니다.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.

적용 대상

추가 정보