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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Jun 30, 2015, 4:50 AM EDT
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.
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Jun 30, 2015, 6:20 PM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Jun 30, 2015, 8:04 PM EDT
Nilesh JadavRank #109 · 20.3K reputationPosted Jun 30, 2015, 9:20 PM EDT
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?)