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

속성 값

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

구현

예제

다음 예제에서는 및 속성 및 메서드를 Namespace사용하는 ModuleToString 방법을 Type 보여 줍니다.

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
    
type MyClass() = class end

namespace global

module Example = 
    let myType = typeof<MyNamespace.MyClass>
    printfn $"Displaying information about {myType}:"
    // Get the namespace of the myClass class.
    printfn $"   Namespace: {myType.Namespace}."
    // Get the name of the ilmodule.
    printfn $"   Module: {myType.Module}."
    // Get the fully qualified type name.
    printfn $"   Fully qualified name: {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.

적용 대상

추가 정보