Export (0) Print
Expand All

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 Value

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

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft