MemberInfo.Module プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)


このプロパティは、利便性向上のために用意されています。これは、DeclaringType プロパティを使用してメンバが宣言されている型を取得し、取得した Type オブジェクトの Module プロパティを呼び出すことと同じです。

次のコード例は、Object を継承するクラスを宣言し、Object.ToString をオーバーライドしています。この例では、クラスの ToString メソッド、および継承された GetHashCode メソッドの MethodInfo オブジェクトを取得し、2 つのメソッドが宣言されているモジュールの名前を表示します。
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
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 */
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 */
import System.*; import System.Reflection.*; public class Test { public String ToString() { return "An instance of class Test!"; } //ToString } //Test public class Example { public static void main(String[] args) { Test t = new Test(); MethodInfo mi = t.GetType().GetMethod("ToString"); Console.WriteLine("{0} is defined in {1}", mi.get_Name(), mi.get_Module().get_Name()); mi = t.GetType().GetMethod("GetHashCode"); Console.WriteLine("{0} is defined in {1}", mi.get_Name(), mi.get_Module().get_Name()); } //main } //Example /* This example produces code similar to the following: ToString is defined in source.exe GetHashCode is defined in mscorlib.dll */

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- MemberInfo.Module プロパティのページへのリンク