The use of two namespaces : Namespace « Language Basics « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » Language Basics » Namespace 
1.5.14.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);
  }
}
Creating a CompanyName.Car object
myCar.make = Toyota
Creating a DifferentCompany.Car object
myOtherCar.make = Porsche
1.5.Namespace
1.5.1.Namespace Introduction
1.5.2.Full qualify name
1.5.3.Simplest namespace with class definition
1.5.4.Declare a namespace
1.5.5.Demonstrate a namespace.
1.5.6.Use fully qualified class name
1.5.7.Two levels of Namespaces
1.5.8.Namespace with dot
1.5.9.Rename the namespaces
1.5.10.Namespaces prevent name conflicts
1.5.11.Namespaces are additive.
1.5.12.Namespaces can be nested
1.5.13.Demonstrate the :: qualifier.
1.5.14.The use of two namespaces
1.5.15.The use of namespace hierarchies
1.5.16.Creates a namespace with a single class
1.5.17.Same class name under different Namespaces
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.