Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

MemberInfo.Module Property

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

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)

public virtual Module Module { get; }
/** @property */
public Module get_Module ()

public function get Module () : Module

Not applicable.

Property Value

The Module in which the type that declares the member represented by the current MemberInfo is defined.

Exception typeCondition

NotImplementedException

This method is not implemented.

This property is provided as a convenience. It is equivalent to using the DeclaringType property to get the type in which the method is declared, and then calling the Module property of the resulting Type object.

The following code example declares a class that inherits Object and overrides Object.ToString. The example obtains MethodInfo objects for the class's ToString method and for the inherited GetHashCode method, and displays the names of the modules in which the two methods are declared.

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
 */

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 Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

Show:
© 2014 Microsoft