Illustrates the use of two namespaces : NameSpace : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » NameSpace »

 

Illustrates the use of two namespaces









    

/*
Mastering Visual C# .NET
by Jason Price, Mike Gunderloy

Publisher: Sybex;
ISBN: 0782129110
*/

/*
  Example6_7.cs illustrates the use of two namespaces
*/


public class Example6_7
{

  public static void Main()
  {

    // create a Sybex.Car object
    System.Console.WriteLine("Creating a Sybex.Car object");
    Sybex.Car myCar = new Sybex.Car();
    myCar.make = "Toyota";
    System.Console.WriteLine("myCar.make = " + myCar.make);

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

  }

}
// create the Sybex namespace
namespace Sybex
{

  // declare the Car class
  public class Car
  {
    public string make;
  }

}


// create the DifferentCompany namespace
namespace DifferentCompany
{

  // declare the Car class
  public class Car
  {
    public string make;
  }

}



           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» NameSpace