Namespace
using System;
// Nested namespace is using one namespace within another.
namespace First
{
namespace Second
{
class Employee
{
// Member variables
private string fname = "John";
private string lname = "Smith";
//methods
public string getFname()
{
return fname;
}
public string getLname()
{
return lname;
}
}
}
}
namespace Third
{
class employer
{
static void Main(string[] args)
{
First.Second.Employee e = new First.Second.Employee(); // Class Employee is within two namespaces, First and Second.
String first_name = e.getFname();
String last_name = e.getLname();
Console.WriteLine("Name of the employee: " + first_name + " " + last_name);
Console.ReadLine();
}
}
}
Output:
Name of the employee: John Smith