Type.Module 屬性

定義

在已定義的目前 Type 中取得模組 (DLL)。Gets the module (the DLL) in which the current Type is defined.

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

屬性值

在目前已定義之 Type 中的模組。The module in which the current Type is defined.

實作

範例

下列範例示範如何Namespace使用和Module ToString屬性以及的方法。 TypeThis 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.

適用於

另請參閱