0

What's namespace and what's it's use and why main function is declared inside namespace........

4th Jan 2017, 6:15 PM
Nitin Kumar
2 Answers
0
A namespace is designed for providing a way to keep one set of names separate from another. The class names declared in one namespace does not conflict with the same class names declared in another. for ex:- namespace definition or declaration namespace namespace_name { // code declarations } complete program code:- using System; namespace first_space { class namespace_cl { public void func() { Console.WriteLine("Inside first_space"); } } } namespace second_space { class namespace_cl { public void func() { Console.WriteLine("Inside second_space"); } } } class TestClass { static void Main(string[] args) { first_space.namespace_cl fc = new first_space.namespace_cl(); second_space.namespace_cl sc = new second_space.namespace_cl(); fc.func(); sc.func(); Console.ReadKey(); } } explanation - here in this program both namespace has same name class but it does not effect the yield output.
4th Jan 2017, 6:23 PM
prakash madariya
prakash madariya - avatar
0
output :- Inside first_space Inside second_space
4th Jan 2017, 6:24 PM
prakash madariya
prakash madariya - avatar