CSharp examples for Custom Type:namespace
Declaring a Namespace
using System;/*from ww w.ja v a 2 s . co m*/ namespace Consts { public class PI { public static double value = 3.14159; private PI() {} // private constructor } public class three { public static int value = 3; private three() {} // private constructor } } namespace MyMath { public class Routine { public static long Add( params int[] args ) { int i = 0; long Answer = 0; for( i = 0; i < args.Length; i++) { Answer += args[i]; } return Answer; } public static long Subtract( int arg1, int arg2 ) { long Answer = 0; Answer = arg1 - arg2; return Answer; } } } class MyApp { public static void Main() { long Result = 0; Result = MyMath.Routine.Add( 1, 2, 3 ); Console.WriteLine("Add result is {0}", Result); Result = MyMath.Routine.Subtract( 5, 2 ); Console.WriteLine("Subtract result is {0}", Result); Console.WriteLine("\nThe value of PI is {0}", Consts.PI.value ); Console.WriteLine("The value of three is {0}", Consts.three.value ); } }