Namespaces are used to organize your program and providing assistance in avoiding name clashes
fully qualified name
alias
A namespace can contain
- another namespace, class, interface, struct, enum, delegate
=====================
using System;
//using ProjectA.TeamA;
//using ProjectA.TeamB;
using PA = ProjectA.TeamA;
using PB = ProjectA.TeamB;
class Program
{
static void Main(string[] args)
{
//ProjectA.TeamA.ClassA.Print(); //fully qualified name
//ClassA.Print(); //ambiguous error as of TeamA & TeamB both have ClassA
//ProjectA.TeamA.ClassA.Print();
//ProjectA.TeamB.ClassA.Print(); //namespace.namespace.class
//using alias
PA.ClassA.Print();
PB.ClassA.Print();
}
}
namespace ProjectA
{
namespace TeamA
{
class ClassA
{
public static void Print()
{
Console.WriteLine("Team A Print Method");
}
}
}
}
namespace ProjectA
{
namespace TeamB
{
class ClassA
{
public static void Print()
{
Console.WriteLine("Team B Print Method");
}
}
}
}
=============
about attachment
add another project and add reference...