Following example shows that one namespace can be nested within another:
using System; using System.Windows.Forms; namespace FirstNameSpace { class Class1 { public void ShowMessage() { MessageBox.Show("Class1"); } } namespace SecondNameSpace { class Class2 { public void ShowMessage() { MessageBox.Show("Class2"); } } } } class Class3 { FirstNameSpace.Class1 cls1 = new FirstNameSpace.Class1(); FirstNameSpace.SecondNameSpace.Class2 cls2 = new FirstNameSpace.SecondNameSpace.Class2(); }
Iin the program,the namespace FirstnameSpace is nested within SecondNameSpace.Thus to refer Class2 , we must qualify it with both namespaces.