When a Namespace is declared inside the other namespace that declaration is called nesting namespaces. You can nest namespaces to any level you want. There are 2 ways to nest the namespaces which are as under:
  • We have nested namespaces to 3 levels. The fully qualified name of Customer class in the below code snippet is ABC.XYZ.PQR.Customer
using System;

namespace ABC

{

namespace XYZ

{

namespace PQR

{

//Our Types(Classes,Interfaces,Structures,Delegates,Enumerations etc..)

class Customer

{

//Class code

}

}

}

}

  • Another approach to nest namespaces is using the dot operator.

using System;
namespace ABC.XYZ.PQR //Nesting namespaces using dot operator

{

// Types(Classes,Interfaces,Structures,Delegates,Enumerations etc..)