MemberInfo.Module 속성

정의

현재 MemberInfo가 나타내는 멤버를 선언하는 형식이 정의된 모듈을 가져옵니다.

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

현재 Module가 나타내는 멤버를 선언하는 형식이 정의된 MemberInfo입니다.

예외

이 메서드가 구현되지 않은 경우

예제

다음 코드 예제에서는 상속 Object 하 고 재정의 하는 클래스를 선언 합니다 Object.ToString. 이 예제에서는 클래스의 ToString 메서드 및 상속된 GetHashCode 메서드에 대한 개체를 가져오 MethodInfo 고 두 메서드가 선언된 모듈의 이름을 표시합니다.

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

설명

이 속성은 편의를 위해 제공됩니다. 메서드가 선언된 형식을 DeclaringType 가져오는 데 속성을 사용한 다음 결과 개체의 속성을 호출 Module 하는 Type 것과 같습니다.

적용 대상

추가 정보