By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,320 Members | 2,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,320 IT Pros & Developers. It's quick & easy.

namespaces

P: n/a
Does C# really HAVE to have namespaces? Isn't there any way I can turn them off?
I did a bit of dabbling in VB.NET but have decided not to switch to it permanantly as I've got too much pre-written generic code in C# and the cast operator overloading thing but one of the things I like about VB.NET is it doesn't enthrust the pointless idea of namespaces on you, even though I notice that you can have them if you want.
Are they turn-off-able?
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Yes, C# must use namespaces. There are things you can do, such as "using"
and alias declarations, but there is no way around it. Namespaces are there
for a purpose - to avoid ambiguity between identifiers used in your program.
When you've written programs that are large enough or use 3rd party
libraries that introduce name clashes, you'll learn to appreciate
namespaces.

Joe
--
Joe Mayo, Author/Instructor
Need C#/.NET training?
visit www.mayosoftware.com
C# Tutorial - www.csharp-station.com

"Beeeeeeeeeeeeves" <Be**************@discussions.microsoft.com> wrote in
message news:98**********************************@microsof t.com...
Does C# really HAVE to have namespaces? Isn't there any way I can turn them off? I did a bit of dabbling in VB.NET but have decided not to switch to it permanantly as I've got too much pre-written generic code in C# and the cast
operator overloading thing but one of the things I like about VB.NET is it
doesn't enthrust the pointless idea of namespaces on you, even though I
notice that you can have them if you want. Are they turn-off-able?

Nov 16 '05 #2

P: n/a
Hi Beeeeeeeeeeeeves,

I fully agree to what Joe said. Yes, there should be a balance. Too many
namespaces are nothing, but annoying. It seems like is not so easy to find
the point where to stop decalring new namespaces.
Anyways if you want to don't decalare a namspace C# will put your code in
one global (unnamed) namespace. All namespaces have access to declarations
in the global namespace and all declarations there are public. The latter
cannot be changed. However, there is no way in the current version to
address that, global, neamespace and if there are (and it is most likely
there will be) name clashes with declarations in other namspaces in some
cases they cannot be resolved. C# 2 has workaround, but the current version
doesn't.

--

Stoitcho Goutsev (100) [C# MVP]
"Joe Mayo [C# MVP]" <jm***@nospamAtCSharpDashStation.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Yes, C# must use namespaces. There are things you can do, such as "using"
and alias declarations, but there is no way around it. Namespaces are there for a purpose - to avoid ambiguity between identifiers used in your program. When you've written programs that are large enough or use 3rd party
libraries that introduce name clashes, you'll learn to appreciate
namespaces.

Joe
--
Joe Mayo, Author/Instructor
Need C#/.NET training?
visit www.mayosoftware.com
C# Tutorial - www.csharp-station.com

"Beeeeeeeeeeeeves" <Be**************@discussions.microsoft.com> wrote in
message news:98**********************************@microsof t.com...
Does C# really HAVE to have namespaces? Isn't there any way I can turn them off?
I did a bit of dabbling in VB.NET but have decided not to switch to it

permanantly as I've got too much pre-written generic code in C# and the

cast operator overloading thing but one of the things I like about VB.NET is it
doesn't enthrust the pointless idea of namespaces on you, even though I
notice that you can have them if you want.
Are they turn-off-able?


Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.