Export (0) Print
Expand All

Type.Module Property

Gets the module (the DLL) in which the current Type is defined.

[Visual Basic]
Public MustOverride ReadOnly Property Module As Module
[C#]
public abstract Module Module {get;}
[C++]
public: __property virtual Module* get_Module() = 0;
[JScript]
public abstract function get Module() : Module;

Property Value

The name of the module in which the current Type is defined.

Example

[Visual Basic, C#, C++] This following example demonstrates a use of the Namespace and Module properties and the ToString method of Type.

[Visual Basic] 
Imports System
Imports Microsoft.VisualBasic
Namespace MyNamespace
    Class [MyClass]
    End Class '[MyClass]
End Namespace 'MyNamespace
Public Class Type_ToString_3
    Public Shared Sub Main()
        Try
            Dim myType As Type = GetType(MyNamespace.MyClass)
            Console.WriteLine(ControlChars.NewLine + "Printing the details of {0}." + ControlChars.NewLine, myType)
            ' Get the namespace of the class Type_ToString_3.
            Console.WriteLine("Namespace: {0}.", myType.Namespace)
            ' Get the name of the module.
            Console.WriteLine("Module: {0}.", myType.Module)
            ' Get the fully qualified common language runtime namespace.
            Console.WriteLine("Fully qualified type: {0}.", myType.ToString())
        Catch e As Exception
            Console.WriteLine("Exception: " + e.Message.ToString())
        End Try
    End Sub 'Main
End Class 'Type_ToString_3

[C#] 
using System;
namespace MyNamespace
{
    class MyClass
    {
    }
}
public class Type_ToString_3
{
    public static void Main()
    {
        try
        {
            Type myType = typeof(MyNamespace.MyClass);
            Console.WriteLine("\nPrinting the details of {0}.\n", myType); 
            // Get the namespace of the class Type_ToString_3.
            Console.WriteLine("Namespace: {0}.", myType.Namespace);
            // Get the name of the module.
            Console.WriteLine("Module: {0}.", myType.Module);
            // Get the fully qualified common language runtime namespace.
            Console.WriteLine("Fully qualified type: {0}.", myType.ToString());
        }
        catch(Exception e)
        {
            Console.WriteLine("Exception: " + e.Message ); 
        }
    }
}

[C++] 
#using <mscorlib.dll>

using namespace System;

namespace MyNamespace {
   __gc class MyClass {
   };
}

int main() {
   try {
      Type*  myType = __typeof(MyNamespace::MyClass);
      Console::WriteLine(S"\nPrinting the details of {0}.\n", myType);
      // Get the namespace of the class MyClass.
      Console::WriteLine(S"Namespace: {0}.", myType->Namespace);
      // Get the name of the module.
      Console::WriteLine(S"Module: {0}.", myType->Module);
      // Get the fully qualified common language runtime namespace.
      Console::WriteLine(S"Fully qualified type: {0}.", myType);
   } catch (Exception* e) {
      Console::WriteLine(S"Exception: {0}", e->Message);
   }
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Type Class | Type Members | System Namespace | Module

Show:
© 2014 Microsoft