Type.Module 属性

定义

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

C#
public abstract System.Reflection.Module Module { get; }

属性值

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

实现

示例

以下示例演示如何使用 NamespaceModule 属性以及 ToStringType方法。

C#
using System;

namespace MyNamespace
{
    class MyClass
    {
    }
}

public class Example
{
    public static void Main()
    {
         Type myType = typeof(MyNamespace.MyClass);
         Console.WriteLine("Displaying information about {0}:", myType);
         // Get the namespace of the myClass class.
         Console.WriteLine("   Namespace: {0}.", myType.Namespace);
         // Get the name of the module.
         Console.WriteLine("   Module: {0}.", myType.Module);
         // Get the fully qualified type name.
         Console.WriteLine("   Fully qualified name: {0}.", myType.ToString());
    }
}
// The example displays the following output:
//    Displaying information about MyNamespace.MyClass:
//       Namespace: MyNamespace.
//       Module: type_tostring.exe.
//       Fully qualified name: MyNamespace.MyClass.

注解

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

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

适用于

产品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

另请参阅