Nested Namespace in C#
Now we are going to learn about the Nested Namespace in C#.
Introduction
Nested namespace is used in hung types of programs. Nested namespace is called as one namespace declared second inside first and third namespace declared inside second. Generally namespace used for providing uniqueness in a class coding avoid for collision.
Example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace one
{
class ClassA
{
public ClassA()
{
Console.WriteLine("hello this is one");
}
}
namespace two
{
class ClassB
{
public ClassB()
{
Console.WriteLine("hello this two");
Console.Read();
}
}
}
}
public class NestedNSDemo
{
public static void Main()
{
one.ClassA a = new one.ClassA();
one.two.ClassB b = new one.two.ClassB();
}
}
}
Output