Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

Type::Namespace Property

Gets the namespace of the Type.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public:
virtual property String^ Namespace {
	String^ get () abstract;
}

Property Value

Type: System::String
The namespace of the Type; nullptr if the current instance has no namespace or represents a generic parameter.

Implements

_Type::Namespace

A namespace is a logical design-time naming convenience, used mainly to define scope in an application and organize classes and other types in a single hierarchical structure. From the viewpoint of the runtime, there are no namespaces.

If the current Type represents a constructed generic type, this property returns the namespace that contains the generic type definition. Similarly, if the current Type represents a generic parameter T, this property returns the namespace that contains the generic type definition that defines T.

If the current Type object represents a generic parameter, this property returns nullptr.

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft