A namespace is a logical container of all the user defined type.
* A namespace may contain one or more of following type.
*With a namespace ,you can declare one or more of following types.
Note:Default namespace in c# is "unnamed" or "global namespace"
* A namespace may contain one or more of following type.
*With a namespace ,you can declare one or more of following types.
Note:Default namespace in c# is "unnamed" or "global namespace"
Program that demonstrates namespace use: C# using System; using A.B.C; namespace E { using D; class Program { static void Main() { // Can access CClass type directly from A.B.C. CClass var1 = new CClass(); // Can access DClass type from D. DClass var2 = new DClass(); // Must explicitely specify F namespace. F.FClass var3 = new F.FClass(); // Display types. Console.WriteLine(var1); Console.WriteLine(var2); Console.WriteLine(var3); } } } namespace A { namespace B { namespace C { public class CClass { } } } } namespace D { public class DClass { } } namespace F { public class FClass { } }
No comments:
Post a Comment