- 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();
- }
- }
Answer:
Display() Method of MyClass in NS1
Display() Method of MyClass in Global Namespace