Defining a Namespace - CSharp Custom Type

CSharp examples for Custom Type:namespace

Introduction

A namespace definition begins with the keyword namespace followed by the namespace name.

namespace namespace_name {

}

The following program demonstrates use of namespaces.

Demo Code

using System;//from  www .  j  a va 2s .  c  o m
namespace n1 {
   class c1 {
      public void func() {
         Console.WriteLine("Inside n1");
      }
   }
}
namespace n2 {
   class c1 {
      public void func() {
         Console.WriteLine("Inside n2");
      }
   }
}
class TestClass {
   static void Main(string[] args) {
      n1.c1 fc = new n1.c1();
      n2.c1 sc = new n2.c1();
      fc.func();
      sc.func();
   }
}

Result


Related Tutorials