How the using statement is used to specify namespaces

image_pdfimage_print

   

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

Publisher: Sybex;
ISBN: 0782129110
*/

/*
  Example6_10.cs illustrates how the using
  statement is used to specify namespaces
*/

using Sybex;
using System;


public class Example6_10
{

  public static void Main()
  {

    // the Console.WriteLine() call uses the System namespace
    Console.WriteLine("Creating a Sybex.Car object");

    // create a Car object (uses the Sybex namespace)
    Car myCar = new Car();

    myCar.make = "Toyota";
    Console.WriteLine("myCar.make = " + myCar.make);

  }

}

namespace Sybex
{

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

}