A
name space can be nested in another name space.
using System; namespace Arithmetic { namespace IntegerArithmetic { class Arithmetic { public static int sum(int a, int b) { return a + b; } } } namespace FloatArithmetic { class Arithmetic { public static float sum(float a, float b) { return a + b; } } } } class Program { static void Main(string[] args) { int result1 = Arithmetic.IntegerArithmetic.Arithmetic.sum(10, 20); Console.WriteLine("Sum of 10 and 20 is {0}", result1); } }
Output
Sum
of 10 and 20 is 30
Notify
above snippet, IntegerArithmetic and FloatArithmetic namespaces are defined
inside Arithmetic namespace.
No comments:
Post a Comment