<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FLanguage_Basics%2FNameSpace</id>
		<title>Csharp/C Sharp/Language Basics/NameSpace - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FLanguage_Basics%2FNameSpace"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Language_Basics/NameSpace&amp;action=history"/>
		<updated>2026-04-30T07:59:26Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Language_Basics/NameSpace&amp;diff=710&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Language_Basics/NameSpace&amp;diff=710&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:18Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Language_Basics/NameSpace&amp;diff=711&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Language_Basics/NameSpace&amp;diff=711&amp;oldid=prev"/>
				<updated>2010-05-26T11:39:36Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==C# Namespaces and Using==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using ThatConsoleClass = System.Console;&lt;br /&gt;
public class NamespacesUsing&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        ThatConsoleClass.WriteLine(&amp;quot;Hello&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Creating an alias==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using MyAlias=MyNamespace.Nested.MyClass;&lt;br /&gt;
namespace MyNamespace {&lt;br /&gt;
  namespace Nested {&lt;br /&gt;
       namespace MyClass {&lt;br /&gt;
             public class Foo&lt;br /&gt;
             {&lt;br /&gt;
                  int _Value;&lt;br /&gt;
                  public Foo() {&lt;br /&gt;
                    _Value = 0;&lt;br /&gt;
                  }&lt;br /&gt;
                  public int getValue()&lt;br /&gt;
                  {&lt;br /&gt;
                    return _Value;&lt;br /&gt;
                  }&lt;br /&gt;
             }&lt;br /&gt;
       }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Test {&lt;br /&gt;
  public static void Main() {&lt;br /&gt;
      MyAlias.Foo myFoo = new MyAlias.Foo();&lt;br /&gt;
      Console.WriteLine(&amp;quot;Value {0}&amp;quot;, myFoo.getValue());&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Define an alias to represent a namespace==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
// &lt;br /&gt;
using CmpDb = YourCompany.SecondPartNamespace.InnerNamespace.YourClass;&lt;br /&gt;
namespace YourCompany.SecondPartNamespace {&lt;br /&gt;
  namespace InnerNamespace {&lt;br /&gt;
    public class YourClass {&lt;br /&gt;
      public static void Open( string tblName ) {&lt;br /&gt;
         System.Console.WriteLine(&amp;quot;{0}&amp;quot;, tblName );&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
public class CH1_14 {&lt;br /&gt;
  public static void Main() {&lt;br /&gt;
    CmpDb.Open(&amp;quot;fred&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Demonstrate a namespace==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C#: The Complete Reference &lt;br /&gt;
by Herbert Schildt &lt;br /&gt;
Publisher: Osborne/McGraw-Hill (March 8, 2002)&lt;br /&gt;
ISBN: 0072134852&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
// Demonstrate a namespace. &lt;br /&gt;
// Declare a namespace for counters. &lt;br /&gt;
namespace Counter { &lt;br /&gt;
  // A simple countdown counter. &lt;br /&gt;
  class CountDown { &lt;br /&gt;
    int val; &lt;br /&gt;
 &lt;br /&gt;
    public CountDown(int n) { val = n; } &lt;br /&gt;
 &lt;br /&gt;
    public void reset(int n) { &lt;br /&gt;
      val = n; &lt;br /&gt;
    } &lt;br /&gt;
 &lt;br /&gt;
    public int count() { &lt;br /&gt;
      if(val &amp;gt; 0) return val--; &lt;br /&gt;
      else return 0; &lt;br /&gt;
    } &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
public class NSDemo1 { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    Counter.CountDown cd1 = new Counter.CountDown(10); &lt;br /&gt;
    int i; &lt;br /&gt;
 &lt;br /&gt;
    do { &lt;br /&gt;
      i = cd1.count(); &lt;br /&gt;
      Console.Write(i + &amp;quot; &amp;quot;); &lt;br /&gt;
    } while(i &amp;gt; 0); &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
 &lt;br /&gt;
    Counter.CountDown cd2 = new Counter.CountDown(20); &lt;br /&gt;
 &lt;br /&gt;
    do { &lt;br /&gt;
      i = cd2.count(); &lt;br /&gt;
      Console.Write(i + &amp;quot; &amp;quot;); &lt;br /&gt;
    } while(i &amp;gt; 0); &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
 &lt;br /&gt;
    cd2.reset(4); &lt;br /&gt;
    do { &lt;br /&gt;
      i = cd2.count(); &lt;br /&gt;
      Console.Write(i + &amp;quot; &amp;quot;); &lt;br /&gt;
    } while(i &amp;gt; 0); &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Demonstrate a namespace 2==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C#: The Complete Reference &lt;br /&gt;
by Herbert Schildt &lt;br /&gt;
Publisher: Osborne/McGraw-Hill (March 8, 2002)&lt;br /&gt;
ISBN: 0072134852&lt;br /&gt;
*/&lt;br /&gt;
// Demonstrate a namespace. &lt;br /&gt;
using System; &lt;br /&gt;
// Bring Counter into view. &lt;br /&gt;
using Counter; &lt;br /&gt;
 &lt;br /&gt;
// Declare a namespace for counters. &lt;br /&gt;
namespace Counter { &lt;br /&gt;
  // A simple countdown counter. &lt;br /&gt;
  class CountDown { &lt;br /&gt;
    int val; &lt;br /&gt;
 &lt;br /&gt;
    public CountDown(int n) { &lt;br /&gt;
      val = n; &lt;br /&gt;
    } &lt;br /&gt;
 &lt;br /&gt;
    public void reset(int n) { &lt;br /&gt;
      val = n; &lt;br /&gt;
    } &lt;br /&gt;
 &lt;br /&gt;
    public int count() { &lt;br /&gt;
      if(val &amp;gt; 0) return val--; &lt;br /&gt;
      else return 0; &lt;br /&gt;
    } &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
public class NSDemo3 { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    // now, CountDown can be used directly. &lt;br /&gt;
    CountDown cd1 = new CountDown(10); &lt;br /&gt;
    int i; &lt;br /&gt;
 &lt;br /&gt;
    do { &lt;br /&gt;
      i = cd1.count(); &lt;br /&gt;
      Console.Write(i + &amp;quot; &amp;quot;); &lt;br /&gt;
    } while(i &amp;gt; 0); &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
 &lt;br /&gt;
    CountDown cd2 = new CountDown(20); &lt;br /&gt;
 &lt;br /&gt;
    do { &lt;br /&gt;
      i = cd2.count(); &lt;br /&gt;
      Console.Write(i + &amp;quot; &amp;quot;); &lt;br /&gt;
    } while(i &amp;gt; 0); &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
 &lt;br /&gt;
    cd2.reset(4); &lt;br /&gt;
    do { &lt;br /&gt;
      i = cd2.count(); &lt;br /&gt;
      Console.Write(i + &amp;quot; &amp;quot;); &lt;br /&gt;
    } while(i &amp;gt; 0); &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
  } &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Demonstrates using as a statement==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Programming Tips &amp;amp; Techniques&lt;br /&gt;
by Charles Wright, Kris Jamsa&lt;br /&gt;
Publisher: Osborne/McGraw-Hill (December 28, 2001)&lt;br /&gt;
ISBN: 0072193794&lt;br /&gt;
*/&lt;br /&gt;
// Using.cs -- Demonstrates using as a statement&lt;br /&gt;
//&lt;br /&gt;
//            Compile this program with the following command line:&lt;br /&gt;
//                C:&amp;gt;csc Using.cs&lt;br /&gt;
using System;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using Pen = System.Drawing.Pen;&lt;br /&gt;
using PaintHandler = System.Windows.Forms.PaintEventHandler;&lt;br /&gt;
namespace nsForm&lt;br /&gt;
{&lt;br /&gt;
    public class UsingForm : Form&lt;br /&gt;
    {&lt;br /&gt;
        public UsingForm ()&lt;br /&gt;
        {&lt;br /&gt;
            this.Text = &amp;quot;Using Statement&amp;quot;;&lt;br /&gt;
            this.Paint += new PaintHandler(this.OnPaint);&lt;br /&gt;
        }&lt;br /&gt;
        static public void Main ()&lt;br /&gt;
        {&lt;br /&gt;
            Application.Run(new UsingForm());&lt;br /&gt;
        }&lt;br /&gt;
        private Color [] clr = new Color []&lt;br /&gt;
                       {&lt;br /&gt;
                            Color.Red,&lt;br /&gt;
                            Color.Green,&lt;br /&gt;
                            Color.Blue&lt;br /&gt;
                       };&lt;br /&gt;
        private void OnPaint (object obj, PaintEventArgs e)&lt;br /&gt;
        {&lt;br /&gt;
            Rectangle client = this.ClientRectangle;&lt;br /&gt;
            int side = (client.Right - client.Left) / 3;&lt;br /&gt;
            for (int x = 0; x &amp;lt; 3; ++x)&lt;br /&gt;
            {&lt;br /&gt;
                using (Pen pen = new Pen(clr[x], (float) 2.0))&lt;br /&gt;
                {&lt;br /&gt;
                    client = Rectangle.Inflate (client, -10, -10);&lt;br /&gt;
                    e.Graphics.DrawEllipse (pen, client);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How the using statement is used to specify namespaces==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
/*&lt;br /&gt;
  Example6_10.cs illustrates how the using&lt;br /&gt;
  statement is used to specify namespaces&lt;br /&gt;
*/&lt;br /&gt;
using Sybex;&lt;br /&gt;
using System;&lt;br /&gt;
&lt;br /&gt;
public class Example6_10&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    // the Console.WriteLine() call uses the System namespace&lt;br /&gt;
    Console.WriteLine(&amp;quot;Creating a Sybex.Car object&amp;quot;);&lt;br /&gt;
    // create a Car object (uses the Sybex namespace)&lt;br /&gt;
    Car myCar = new Car();&lt;br /&gt;
    myCar.make = &amp;quot;Toyota&amp;quot;;&lt;br /&gt;
    Console.WriteLine(&amp;quot;myCar.make = &amp;quot; + myCar.make);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
namespace Sybex&lt;br /&gt;
{&lt;br /&gt;
  // declare the Car class&lt;br /&gt;
  public class Car&lt;br /&gt;
  {&lt;br /&gt;
    public string make;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Illustrates the use of two namespaces==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
/*&lt;br /&gt;
  Example6_7.cs illustrates the use of two namespaces&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
public class Example6_7&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    // create a Sybex.Car object&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;Creating a Sybex.Car object&amp;quot;);&lt;br /&gt;
    Sybex.Car myCar = new Sybex.Car();&lt;br /&gt;
    myCar.make = &amp;quot;Toyota&amp;quot;;&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;myCar.make = &amp;quot; + myCar.make);&lt;br /&gt;
    // create a DifferentCompany.Car object&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;Creating a DifferentCompany.Car object&amp;quot;);&lt;br /&gt;
    DifferentCompany.Car myOtherCar = new DifferentCompany.Car();&lt;br /&gt;
    myOtherCar.make = &amp;quot;Porsche&amp;quot;;&lt;br /&gt;
    System.Console.WriteLine(&amp;quot;myOtherCar.make = &amp;quot; + myOtherCar.make);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
// create the Sybex namespace&lt;br /&gt;
namespace Sybex&lt;br /&gt;
{&lt;br /&gt;
  // declare the Car class&lt;br /&gt;
  public class Car&lt;br /&gt;
  {&lt;br /&gt;
    public string make;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// create the DifferentCompany namespace&lt;br /&gt;
namespace DifferentCompany&lt;br /&gt;
{&lt;br /&gt;
  // declare the Car class&lt;br /&gt;
  public class Car&lt;br /&gt;
  {&lt;br /&gt;
    public string make;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Namespaces are additive==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C#: The Complete Reference &lt;br /&gt;
by Herbert Schildt &lt;br /&gt;
Publisher: Osborne/McGraw-Hill (March 8, 2002)&lt;br /&gt;
ISBN: 0072134852&lt;br /&gt;
*/&lt;br /&gt;
// Namespaces are additive. &lt;br /&gt;
 &lt;br /&gt;
using System; &lt;br /&gt;
 &lt;br /&gt;
// Bring Counter into view. &lt;br /&gt;
using Counter; &lt;br /&gt;
 &lt;br /&gt;
// Here is one Counter namespace. &lt;br /&gt;
namespace Counter { &lt;br /&gt;
  // A simple countdown counter. &lt;br /&gt;
  class CountDown { &lt;br /&gt;
    int val; &lt;br /&gt;
 &lt;br /&gt;
    public CountDown(int n) { &lt;br /&gt;
      val = n; &lt;br /&gt;
    } &lt;br /&gt;
 &lt;br /&gt;
    public void reset(int n) { &lt;br /&gt;
      val = n; &lt;br /&gt;
    } &lt;br /&gt;
 &lt;br /&gt;
    public int count() { &lt;br /&gt;
      if(val &amp;gt; 0) return val--; &lt;br /&gt;
      else return 0; &lt;br /&gt;
    } &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
// Here is another Counter namespace. &lt;br /&gt;
namespace Counter { &lt;br /&gt;
  // A simple count-up counter. &lt;br /&gt;
  class CountUp { &lt;br /&gt;
    int val; &lt;br /&gt;
    int target; &lt;br /&gt;
 &lt;br /&gt;
    public int Target { &lt;br /&gt;
      get{ &lt;br /&gt;
        return target; &lt;br /&gt;
      } &lt;br /&gt;
    } &lt;br /&gt;
 &lt;br /&gt;
    public CountUp(int n) { &lt;br /&gt;
      target = n; &lt;br /&gt;
      val = 0; &lt;br /&gt;
    } &lt;br /&gt;
 &lt;br /&gt;
    public void reset(int n) { &lt;br /&gt;
      target = n; &lt;br /&gt;
      val = 0; &lt;br /&gt;
    } &lt;br /&gt;
 &lt;br /&gt;
    public int count() { &lt;br /&gt;
      if(val &amp;lt; target) return val++; &lt;br /&gt;
      else return target; &lt;br /&gt;
    } &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
public class NSDemo5 { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    CountDown cd = new CountDown(10); &lt;br /&gt;
    CountUp cu = new CountUp(8); &lt;br /&gt;
    int i; &lt;br /&gt;
 &lt;br /&gt;
    do { &lt;br /&gt;
      i = cd.count(); &lt;br /&gt;
      Console.Write(i + &amp;quot; &amp;quot;); &lt;br /&gt;
    } while(i &amp;gt; 0); &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
 &lt;br /&gt;
    do { &lt;br /&gt;
      i = cu.count(); &lt;br /&gt;
      Console.Write(i + &amp;quot; &amp;quot;); &lt;br /&gt;
    } while(i &amp;lt; cu.Target); &lt;br /&gt;
 &lt;br /&gt;
  } &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Namespaces can be nested==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C#: The Complete Reference &lt;br /&gt;
by Herbert Schildt &lt;br /&gt;
Publisher: Osborne/McGraw-Hill (March 8, 2002)&lt;br /&gt;
ISBN: 0072134852&lt;br /&gt;
*/&lt;br /&gt;
// Namespaces can be nested. &lt;br /&gt;
 &lt;br /&gt;
using System; &lt;br /&gt;
 &lt;br /&gt;
namespace NS1 { &lt;br /&gt;
  class ClassA { &lt;br /&gt;
     public ClassA() { &lt;br /&gt;
       Console.WriteLine(&amp;quot;constructing ClassA&amp;quot;); &lt;br /&gt;
    } &lt;br /&gt;
  } &lt;br /&gt;
  namespace NS2 { // a nested namespace &lt;br /&gt;
    class ClassB { &lt;br /&gt;
       public ClassB() { &lt;br /&gt;
         Console.WriteLine(&amp;quot;constructing ClassB&amp;quot;); &lt;br /&gt;
      } &lt;br /&gt;
    } &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
public class NestedNSDemo { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    NS1.ClassA a= new NS1.ClassA(); &lt;br /&gt;
 &lt;br /&gt;
 // NS2.ClassB b = new NS2.ClassB(); // Error!!! NS2 is not in view &lt;br /&gt;
 &lt;br /&gt;
    NS1.NS2.ClassB b = new NS1.NS2.ClassB(); // this is right &lt;br /&gt;
  } &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Namespaces prevent name conflicts==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C#: The Complete Reference &lt;br /&gt;
by Herbert Schildt &lt;br /&gt;
Publisher: Osborne/McGraw-Hill (March 8, 2002)&lt;br /&gt;
ISBN: 0072134852&lt;br /&gt;
*/&lt;br /&gt;
// Namespaces prevent name conflicts. &lt;br /&gt;
  &lt;br /&gt;
using System;  &lt;br /&gt;
  &lt;br /&gt;
// Declare a namespace for counters.  &lt;br /&gt;
namespace Counter {  &lt;br /&gt;
  // A simple countdown counter.  &lt;br /&gt;
  class CountDown {  &lt;br /&gt;
    int val;  &lt;br /&gt;
  &lt;br /&gt;
    public CountDown(int n) { &lt;br /&gt;
      val = n; &lt;br /&gt;
    }  &lt;br /&gt;
  &lt;br /&gt;
    public void reset(int n) {  &lt;br /&gt;
      val = n;  &lt;br /&gt;
    }  &lt;br /&gt;
  &lt;br /&gt;
    public int count() {  &lt;br /&gt;
      if(val &amp;gt; 0) return val--;  &lt;br /&gt;
      else return 0;  &lt;br /&gt;
    }  &lt;br /&gt;
  }  &lt;br /&gt;
}  &lt;br /&gt;
 &lt;br /&gt;
// Declare another namespace.  &lt;br /&gt;
namespace Counter2 {  &lt;br /&gt;
  /* This CountDown is in the default namespace and  &lt;br /&gt;
     does not conflict with the one in Counter. */ &lt;br /&gt;
  class CountDown { &lt;br /&gt;
    public void count() { &lt;br /&gt;
      Console.WriteLine(&amp;quot;This is count() in the &amp;quot; + &lt;br /&gt;
                        &amp;quot;Counter2 namespace.&amp;quot;); &lt;br /&gt;
    } &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
public class NSDemo2 {  &lt;br /&gt;
  public static void Main() {  &lt;br /&gt;
    // This is CountDown in the Counter namespace. &lt;br /&gt;
    Counter.CountDown cd1 = new Counter.CountDown(10);  &lt;br /&gt;
 &lt;br /&gt;
    // This is CountDown in the default namespace. &lt;br /&gt;
    Counter2.CountDown cd2 = new Counter2.CountDown(); &lt;br /&gt;
 &lt;br /&gt;
    int i;  &lt;br /&gt;
  &lt;br /&gt;
    do {  &lt;br /&gt;
      i = cd1.count();  &lt;br /&gt;
      Console.Write(i + &amp;quot; &amp;quot;);  &lt;br /&gt;
    } while(i &amp;gt; 0);  &lt;br /&gt;
    Console.WriteLine();  &lt;br /&gt;
  &lt;br /&gt;
    cd2.count(); &lt;br /&gt;
  }  &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==The use of namespace hierarchies (part 1)==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
/*&lt;br /&gt;
  Example6_8.cs illustrates the use of namespace&lt;br /&gt;
  hierarchies (part 1)&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
public class Example6_8&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    Sybex.UserInterface.MyClass myUI = new Sybex.UserInterface.MyClass();&lt;br /&gt;
    Sybex.DatabaseAccess.MyClass myDB = new Sybex.DatabaseAccess.MyClass();&lt;br /&gt;
    // uses class in MiddleTier namespace in Example6_9&lt;br /&gt;
    Sybex.MiddleTier.MyClass myMT = new Sybex.MiddleTier.MyClass();&lt;br /&gt;
    // call the Test() methods&lt;br /&gt;
    myUI.Test();&lt;br /&gt;
    myDB.Test();&lt;br /&gt;
    myMT.Test();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
namespace Sybex&lt;br /&gt;
{&lt;br /&gt;
  namespace UserInterface  // nested namespace&lt;br /&gt;
  {&lt;br /&gt;
    public class MyClass&lt;br /&gt;
    {&lt;br /&gt;
      public void Test()&lt;br /&gt;
      {&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;UserInterface Test()&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
namespace Sybex.DatabaseAccess  // nested namespace using dot&lt;br /&gt;
{&lt;br /&gt;
  public class MyClass&lt;br /&gt;
  {&lt;br /&gt;
    public void Test()&lt;br /&gt;
    {&lt;br /&gt;
      System.Console.WriteLine(&amp;quot;DatabaseAccess Test()&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
  Example6_9.cs illustrates the use of namespace&lt;br /&gt;
  hierarchies (part 2)&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
namespace Sybex  // use the Sybex namespace&lt;br /&gt;
{&lt;br /&gt;
  namespace MiddleTier  // another namespace&lt;br /&gt;
  {&lt;br /&gt;
    public class MyClass {&lt;br /&gt;
      public void Test() {&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;MiddleTier Test()&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Using namespace==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Programming Tips &amp;amp; Techniques&lt;br /&gt;
by Charles Wright, Kris Jamsa&lt;br /&gt;
Publisher: Osborne/McGraw-Hill (December 28, 2001)&lt;br /&gt;
ISBN: 0072193794&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
namespace nsFirst&lt;br /&gt;
{&lt;br /&gt;
    public class NameSpaceDemo&lt;br /&gt;
    {&lt;br /&gt;
        static public void Main ()&lt;br /&gt;
        {&lt;br /&gt;
            nsSecond.clsClass cls = new nsSecond.clsClass ();&lt;br /&gt;
            for (nsNested.WeekDays x = nsNested.WeekDays.Sunday; x &amp;lt; nsNested.WeekDays.DaysInWeek; ++x)&lt;br /&gt;
                cls.ShowDay (x);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    namespace nsNested&lt;br /&gt;
    {&lt;br /&gt;
       public enum WeekDays&lt;br /&gt;
              {&lt;br /&gt;
                  Sunday, Monday, Tuesday, Wednesday,&lt;br /&gt;
                  Thursday, Friday, Saturday, DaysInWeek&lt;br /&gt;
              };&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
namespace nsSecond&lt;br /&gt;
{&lt;br /&gt;
    class clsClass&lt;br /&gt;
    {&lt;br /&gt;
        public void ShowDay (nsFirst.nsNested.WeekDays day)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine (day);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Using the alias keyword to refer to a nested namespace==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
// &lt;br /&gt;
using CmpDb = YourCompany.SecondPartNamespace.InnerNamespace.YourClass;&lt;br /&gt;
namespace YourCompany.SecondPartNamespace {&lt;br /&gt;
  namespace InnerNamespace {&lt;br /&gt;
    public class YourClass {&lt;br /&gt;
      public static void Open( string tblName ) {&lt;br /&gt;
         System.Console.WriteLine(&amp;quot;{0}&amp;quot;, tblName );&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
public class CH1_14 {&lt;br /&gt;
  public static void Main() {&lt;br /&gt;
    CmpDb.Open(&amp;quot;fred&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>