MemberInfo.Module 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得定義宣告電流所代表 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定義了宣告由電流MemberInfo所代表成員的類型。
例外狀況
未實作此方法。
範例
以下程式碼範例宣告一個繼 Object 承並覆寫 Object.ToString的類別。 範例取得 MethodInfo 類別 ToString 方法與繼承 GetHashCode 方法的物件,並顯示兩種方法宣告的模組名稱。
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 的屬性。