The use of two namespaces : Namespace : Language Basics C# Examples


C# Examples » Language Basics » Namespace »

 

The use of two namespaces









    
namespace  CompanyName
{
    public  class  Car
    {
        public  string  make;
    }

}

namespace  DifferentCompany
{
    public  class  Car
    {
        public  string  make;
    }

}

class  MainClass
{

    public  static  void  Main()
    {
        System.Console.WriteLine("Creating  a  CompanyName.Car  object");
        CompanyName.Car  myCar  =  new  CompanyName.Car();
        myCar.make  =  "Toyota";
        System.Console.WriteLine("myCar.make  =  "  +  myCar.make);

        System.Console.WriteLine("Creating  a  DifferentCompany.Car  object");
        DifferentCompany.Car  myOtherCar  =  new  DifferentCompany.Car();
        myOtherCar.make  =  "Porsche";
        System.Console.WriteLine("myOtherCar.make  =  "  +  myOtherCar.make);
    }
}
    
   
  
   



Output

Creating a CompanyName.Car object
myCar.make = Toyota
Creating a DifferentCompany.Car object
myOtherCar.make = Porsche


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Language Basics
» Namespace