다음을 통해 공유


Type.Namespace 속성

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

네임스페이스: System
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
Public MustOverride ReadOnly Property Namespace As String
‘사용 방법
Dim instance As Type
Dim value As String

value = instance.Namespace
public abstract string Namespace { get; }
public:
virtual property String^ Namespace {
    String^ get () abstract;
}
/** @property */
public abstract String get_Namespace ()
public abstract function get Namespace () : String

속성 값

Type의 네임스페이스입니다. 현재 인스턴스가 제네릭 매개 변수를 나타내면 Null 참조(Visual Basic의 경우 Nothing)입니다.

설명

네임스페이스는 일반적으로 응용 프로그램의 범위를 정의하고 클래스와 기타 형식을 단일 계층적 구조로 구성하는 데 사용되는 디자인 타임 관점의 논리적인 스키마입니다. 런타임의 관점에서 볼 때 네임스페이스는 없습니다.

현재 Type이 생성된 제네릭 형식을 나타내는 경우 이 속성은 제네릭 형식 정의가 포함된 네임스페이스를 반환합니다. 마찬가지로, 현재 Type이 제네릭 매개 변수 T를 나타내는 경우 이 속성은 T를 정의하는 제네릭 형식 정의가 포함된 네임스페이스를 반환합니다.

현재 Type 개체가 제네릭 매개 변수를 나타내는 경우 이 속성은 Null 참조(Visual Basic의 경우 Nothing)을 반환합니다.

예제

다음 예제에서는 NamespaceModule 속성과 TypeToString 메서드를 사용하는 방법을 보여 줍니다.

Imports System
Imports Microsoft.VisualBasic
Namespace MyNamespace
    Class [MyClass]
    End Class '[MyClass]
End Namespace 'MyNamespace
Public Class Type_ToString_3
    Public Shared Sub Main()
        Try
            Dim myType As Type = GetType(MyNamespace.MyClass)
            Console.WriteLine(ControlChars.NewLine + "Printing the details of {0}." + ControlChars.NewLine, myType)
            ' Get the namespace of the class Type_ToString_3.
            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.ToString())
        Catch e As Exception
            Console.WriteLine("Exception: " + e.Message.ToString())
        End Try
    End Sub 'Main
End Class 'Type_ToString_3
using System;
namespace MyNamespace
{
    class MyClass
    {
    }
}
public class Type_ToString_3
{
    public static void Main()
    {
        try
        {
            Type myType = typeof(MyNamespace.MyClass);
            Console.WriteLine("\nPrinting the details of {0}.\n", myType); 
            // Get the namespace of the class Type_ToString_3.
            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.ToString());
        }
        catch(Exception e)
        {
            Console.WriteLine("Exception: " + e.Message ); 
        }
    }
}
using namespace System;

namespace MyNamespace
{
   ref class MyClass{};

}

int main()
{
   try
   {
      Type^ myType = MyNamespace::MyClass::typeid;
      Console::WriteLine( "\nPrinting the details of {0}.\n", 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 );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception: {0}", e->Message );
   }
}
package MyNamespace;
 
import System.*;

class MyClass
{
} //MyClass

public class Type_ToString_3
{
    public static void main(String[] args)
    {
        try {
            Type myType = MyNamespace.MyClass.class.ToType();
            Console.WriteLine("\nPrinting the details of {0}.\n", myType);

            // Get the namespace of the class Type_ToString_3.
            Console.WriteLine("Namespace: {0}.", myType.get_Namespace());

            // Get the name of the module.
            Console.WriteLine("Module: {0}.", myType.get_Module());

            // Get the fully qualified common language runtime namespace.
            Console.WriteLine("Fully qualified type: {0}.", myType.ToString());
        }
        catch (System.Exception e) {
            Console.WriteLine("Exception: " + e.get_Message());
        }
    } //main
} //Type_ToString_3

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

Type 클래스
Type 멤버
System 네임스페이스
String 클래스
Type.FullName 속성
Type.AssemblyQualifiedName 속성

기타 리소스

정규화된 형식 이름 지정