Type.Module 属性
定义
public:
abstract property System::Reflection::Module ^ Module { System::Reflection::Module ^ get(); };
public abstract System.Reflection.Module Module { get; }
member this.Module : System.Reflection.Module
Public MustOverride ReadOnly Property Module As Module
属性值
实现
示例
下面的示例演示如何使用 Namespace 和 Module
属性以及 Type的 ToString 方法。This following example demonstrates a use of the Namespace and Module
properties and the ToString method of Type.
using namespace System;
namespace MyNamespace
{
ref class MyClass
{
};
}
void main()
{
Type^ myType = MyNamespace::MyClass::typeid;
Console::WriteLine("Displaying information about {0}:", 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 );
}
// The example displays the following output:
// Displaying information about MyNamespace.MyClass:
// Namespace: MyNamespace
// Module: type_tostring.exe
// Fully qualified name: MyNamespace.MyClass
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.
Namespace MyNamespace
Class [MyClass]
End Class
End Namespace
Public Class Example
Public Shared Sub Main()
Dim myType As Type = GetType(MyNamespace.MyClass)
Console.WriteLine(", 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())
End Sub
End Class
' The example displays the following output:
' Displaying information about MyNamespace.MyClass:
' Namespace: MyNamespace.
' Module: type_tostring.exe.
' Fully qualified name: MyNamespace.MyClass.
注解
如果当前 Type 表示构造的泛型类型,则此属性返回定义了泛型类型定义的模块。If the current Type represents a constructed generic type, this property returns the module in which the generic type definition was defined. 例如,如果创建 MyGenericStack<int>
的实例,则构造类型的 Module 属性将返回定义 MyGenericStack<T>
的模块。For example, if you create an instance of MyGenericStack<int>
, the Module property for the constructed type returns the module in which MyGenericStack<T>
is defined.
同样,如果当前 Type 表示泛型参数 T
,则此属性将返回包含定义 T
的泛型类型的程序集。Similarly, if the current Type represents a generic parameter T
, this property returns the assembly that contains the generic type that defines T
.