Get the namespace of the Type in CSharp
Description
The following code shows how to get the namespace of the Type.
Example
//w ww . j ava 2s.c o m
using System;
namespace MyNamespace
{
class MyClass
{
}
}
public class Example
{
public static void Main()
{
Type myType = typeof(MyNamespace.MyClass);
Console.WriteLine(" Namespace: {0}.", myType.Namespace);
}
}
The code above generates the following result.