What is the use of namespace in C#. Please elaborate.
And what if name space is not used? Will it effect the visibility of my class?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Nilesh JadavPosted Jul 1, 2015, 1:20 AM
Namespace:
Declaration of Namespaces:
- using System;
- using System.Data;
// Namespace Declaration in VBAdvantages:
Well If you don't use Namespace in your application then you can import the library, for example suppose , if you want to bind gridview using sql server, for that you have you use:
Sqlconnection
SqlCommand
dataTable
SqlDataReader ..
all these you have to use for binding purpose , to use this you have to import these namespaces
Using System.Data;
If you will not use these namespaces then in your application the intellisence of VS1o will not showing you the SqlConnection , and all the necessary code that requires in binding.
error of namespace : [If you will not import the namespace]
The type or namespace name 'MyControl' does not exist in the namespace 'MyNamespace' (are you missing an assembly reference?)
Rajeesh MenothPosted Jul 1, 2015, 12:04 AM
Pankaj Kumar ChoudharyPosted Jun 30, 2015, 10:20 PM
Upendra Pratap ShahiPosted Jun 30, 2015, 8:50 AM
Need for Namespaces
Namespaces allow you to create a system to organize your code. A good way to organize your namespaces is via a hierarchical system. You put the more general names at the top of the hierarchy and get more specific as you go down. This hierarchical system can be represented by nested namespaces.By placing code in different sub-namespaces, you can keep your code organized.