Type.Namespace 속성

정의

Type의 네임스페이스를 가져옵니다.

public:
 abstract property System::String ^ Namespace { System::String ^ get(); };
public abstract string Namespace { get; }
public abstract string? Namespace { get; }
member this.Namespace : string
Public MustOverride ReadOnly Property Namespace As String

속성 값

String

Type의 네임스페이스입니다. 현재 인스턴스가 제네릭 매개 변수를 나타내거나 네임스페이스가 없으면 null입니다.

구현

예제

다음 예제에서는 Namespace Module 의 및 속성과 메서드를 사용 하는 방법을 보여 줍니다 ToString 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 이 생성 된 제네릭 형식을 나타내는 경우이 속성은 제네릭 형식 정의를 포함 하는 네임 스페이스를 반환 합니다. 마찬가지로, 현재 Type 이 제네릭 매개 변수를 나타내는 경우 T 이 속성은을 정의 하는 제네릭 형식 정의를 포함 하는 네임 스페이스를 반환 T 합니다.

현재 Type 개체가 제네릭 매개 변수를 나타내지만 제네릭 형식 정의를 사용할 수 없는 경우 (예:에서 반환 되는 서명 형식의 경우) MakeGenericMethodParameter 이 속성은를 반환 null 합니다.

적용 대상

추가 정보