Share via


Type.Module 属性

获取在其中定义当前 Type 的模块 (DLL)。

**命名空间:**System
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
Public MustOverride ReadOnly Property Module As Module
用法
Dim instance As Type
Dim value As Module

value = instance.Module
public abstract Module Module { get; }
public:
virtual property Module^ Module {
    Module^ get () abstract override;
}
/** @property */
public abstract Module get_Module ()
public abstract function get Module () : Module

属性值

在其中定义当前 Type 的模块的名称。

备注

如果当前 Type 表示构造泛型类型,则此属性 (Property) 将返回定义该类型的模块。例如,如果创建 MyGenericStack<int> 的实例,构造类型的 Module 属性 (Property) 将返回在其中定义 MyGenericStack<T> 的模块。

类似地,如果当前 Type 表示泛型参数 T,则此属性返回包含定义 T 的泛型类型的程序集。

示例

下面的示例说明如何使用 TypeNamespaceModule 属性 (Property) 以及 ToString 方法。

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
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 ); 
        }
    }
}
using namespace System;

namespace MyNamespace
{
   ref class MyClass{};

}

int main()
{
   try
   {
      Type^ myType = MyNamespace::MyClass::typeid;
      Console::WriteLine( "\nPrinting the details of {0}.\n", myType );
      
      // Get the namespace of the class MyClass.
      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 );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception: {0}", e->Message );
   }
}
package MyNamespace;
 
import System.*;

class MyClass
{
} //MyClass

public class Type_ToString_3
{
    public static void main(String[] args)
    {
        try {
            Type myType = MyNamespace.MyClass.class.ToType();
            Console.WriteLine("\nPrinting the details of {0}.\n", myType);

            // Get the namespace of the class Type_ToString_3.
            Console.WriteLine("Namespace: {0}.", myType.get_Namespace());

            // Get the name of the module.
            Console.WriteLine("Module: {0}.", myType.get_Module());

            // Get the fully qualified common language runtime namespace.
            Console.WriteLine("Fully qualified type: {0}.", myType.ToString());
        }
        catch (System.Exception e) {
            Console.WriteLine("Exception: " + e.get_Message());
        }
    } //main
} //Type_ToString_3

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

Type 类
Type 成员
System 命名空间
Module