Aliasing Namespace Names : Namespace Alias « Language Basics « C# / CSharp Tutorial






using N1 = Namespace1;
using N2 = Namespace2;
   
namespace Namespace1
{
    class TestClass
    {
        public TestClass()
        {
            System.Console.WriteLine("Hello from Namespace1.TestClass!");
        }
    }
}
   
namespace Namespace2
{
    class TestClass
    {
        public TestClass()
        {
            System.Console.WriteLine("Hello from Namespace2.TestClass!");
        }
    }
}
   
class MainClass
{
    public static void Main()
    {
        N1.TestClass Object1 = new N1.TestClass();
        N2.TestClass Object2 = new N2.TestClass();
    }
}








1.6.Namespace Alias
1.6.1.Use the global alias.
1.6.2.Aliasing Namespace Names
1.6.3.Aliasing Class Names
1.6.4.Using a Namespace Directive
1.6.5.Using the alias keyword to refer to a nested namespace.
1.6.6.Simple Aliases for namespace
1.6.7.Global Namespace Alias