Use namespace to hold classes - CSharp Custom Type

CSharp examples for Custom Type:namespace

Description

Use namespace to hold classes

Demo Code

using System;//from   ww  w . ja v a2s  . co m
namespace Numbers
{
   public class one
   {
      public static int value = 1;
      private one() {}
   }
   public class two
   {
      public static int value = 2;
      private two() {}
   }
   namespace Special
   {
      public class PI
      {
         public static double value = 3.14159;
         private PI() {}
      }
   }
}
class MyApp
{
   public static void Main()
   {
      Console.WriteLine("One is {0}", Numbers.one.value);
      Console.WriteLine("Two is {0}", Numbers.two.value);
      Console.WriteLine("PI is {0}", Numbers.Special.PI.value);
   }
}

Result


Related Tutorials