C# Type Namespace

Description

Type Namespace gets the namespace of the Type.

Syntax

Type.Namespace has the following syntax.


public abstract string Namespace { get; }

Example

This following example demonstrates a use of the Namespace and Module properties and the ToString method of Type.


using System;//from   w w w .j a  v  a 2  s  . c o m

namespace MyNamespace
{
    class MyClass
    {
    }
}

public class Example
{
    public static void Main()
    {
         Type myType = typeof(MyNamespace.MyClass);
         Console.WriteLine("Displaying information about {0}:", myType); 
         Console.WriteLine("   Namespace: {0}.", myType.Namespace);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version