Same class name under different Namespaces : Namespace : Language Basics C# Examples


C# Examples » Language Basics » Namespace »

 

Same class name under different Namespaces









    
using  System;          

namespace  Foo  {

    public  class  Money  {
        public  Money()  {
        }
        public  void  Print(  )  {
            Console.WriteLine("Foo.Money.Print");
        }
    }
}

namespace  Bar  {

    public  class  Money  {
        public  Money(  )  {
        }
        public  void  Print(  )  {
            Console.WriteLine("Bar.Money.Print");
        }
    }
}


public  class  MainClass  {
    public  static  void  Main(  )  {
        Foo.Money  fm  =  new  Foo.Money();
        Bar.Money  bm  =  new  Bar.Money();
        fm.Print(  );
        bm.Print(  );
    }
}
    
   
  
   



Output

Foo.Money.Print
Bar.Money.Print


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Language Basics
» Namespace