Using Namespace Alias Qualifier Operator C# with Example



Using Namespace Alias Qualifier Operator C# with Example

 	using System;
	using NS1;
	using NS2;
	
	using MyNS = NS1;
	using YourNS = NS2;

	namespace NS1
	{
		public class MyClass
		{
			public void Display()
			{
				Console.WriteLine("Display() Method of MyClass in NS1");
			}
		}
	}
	
	namespace NS2
	{
		public class MyClass
		{
			public void Display()
			{
				Console.WriteLine("Display() Method of MyClass in NS2");
			}
		}
	}
	
	class UsingMyClass
	{
		public static void Main()
		{
			MyNS::MyClass myObject = new MyNS::MyClass();
			myObject.Display();
			
			YourNS::MyClass yourObject = new YourNS::MyClass();
			yourObject.Display();
		}
	}
 

0 Comment's

Comment Form