Global Namespace With Alias Qualifier Operator C# with Example



Global Namespace With Alias Qualifier Operator C# with Example

 	using System;
	using NS1;
	
	using MyNS = NS1;

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

0 Comment's

Comment Form

Submit Comment