+ 1

What is uses of namespace in c#?

I create 2 program with 2 class. first with namespace and second without namespace. What is difference between them? Both are working like same.

20th Dec 2017, 4:58 PM
Nischal Kumar
Nischal Kumar - avatar
3 Respostas
21st Dec 2017, 7:52 AM
Rasul Abbasi
Rasul Abbasi - avatar
+ 1
Hi, namespaces use for managing your dlls and projects. Classes with the same namespace must have unique name. Therefore you can define classes with same name in different namespaces. Namespace tells you where your classes belong to, then it can be infered from namespace that what kind of responsibities your class might have. For example you can have three class with name of "Order", with three different namespaces as follow: " domain.entity" , "domain.service" , "presentation.viewmodels". Each of these classes have different responsibility which I am sure you can comprehend them as you see their namespace.
21st Dec 2017, 7:50 AM
Rasul Abbasi
Rasul Abbasi - avatar
0
when our project has many classes then it is difficult to manage them . so namespace is used for grouping the related class together.
13th Jan 2018, 4:13 PM
Priti K
Priti K - avatar