Mega Code Archive

 
Categories / C# / Reflection
 

Gets the module in which the type that declares the member represented by the current MemberInfo is defined

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);     } }