MemberInfo.Module プロパティ
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
現在の MemberInfo によって表されるメンバーを宣言する型が定義されているモジュールを取得します。
public:
virtual property System::Reflection::Module ^ Module { System::Reflection::Module ^ get(); };
C#
public virtual System.Reflection.Module Module { get; }
member this.Module : System.Reflection.Module
Public Overridable ReadOnly Property Module As Module
現在の Module によって表されるメンバーを宣言する型が定義されている MemberInfo。
このメソッドは実装されていません。
次のコード例では、 を継承してオーバーライドするクラスを Object 宣言します Object.ToString。 この例では、MethodInfoクラスの メソッドと継承されたGetHashCodeメソッドの ToString
オブジェクトを取得し、2 つのメソッドが宣言されているモジュールの名前を表示します。
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
*/
C#
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使用してメソッドが宣言されている型を取得し、結果のTypeオブジェクトの プロパティをModule呼び出すのと同じです。
製品 | バージョン |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
UWP | 10.0 |
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。