Ramifications of No Namespace

  • Thread starter Thread starter Jonathan Wood
  • Start date Start date
J

Jonathan Wood

Greetings,

Normally, when I create C# modules, the class appears within a namespace.

However, I've just created a Web service and new classes have no namespace.

Can anyone tell me why this is? And what the ramifications are of having or
not having classes defined within a namespace?

Thanks!
 
Namespaces are just a way to give a unique name to your
class in the "application". They are not required but are
suggested.

--
Robbe Morris - 2004-2006 Microsoft MVP C#
I've mapped the database to .NET class properties and methods to
implement an multi-layered object oriented environment for your
data access layer. Thus, you should rarely ever have to type the words
SqlCommand, SqlDataAdapter, or SqlConnection again.
http://www.eggheadcafe.com/articles/adonet_source_code_generator.asp
 
Hmmm... makes you wonder why VS would insert a namespace in one case and not
in another. Perhaps it has something to do with the fact that it is a Web
service and would not normally be access via local code that would have
access to the namespace - ???

Thanks.
 
Hi,

Jonathan said:
Hmmm... makes you wonder why VS would insert a namespace in one case and not
in another. Perhaps it has something to do with the fact that it is a Web
service and would not normally be access via local code that would have
access to the namespace - ???

Thanks.

Normally, VS includes a namespace in a new class, also for web services.
The namespace is based on the default namespace for the project (set
in the project's properties) and the folder hierarchy relative to the root.

Did you happen to delete the default namespace in the project's properties?

Greetings,
Laurent
 
Laurent,
Normally, VS includes a namespace in a new class, also for web services.
The namespace is based on the default namespace for the project (set in
the project's properties) and the folder hierarchy relative to the root.

Did you happen to delete the default namespace in the project's
properties?

I really don't think so. I just created a new project and then added that
class using the Wizards. It created a new file with a class not encloded in
any namespace block.

I don't see the setting you referred to. It's a Web site, not a project. I
can only assume that has something to do with why it didn't automatically
include a namespace in my new class - ???
 
Hi,

Jonathan said:
I really don't think so. I just created a new project and then added that
class using the Wizards. It created a new file with a class not encloded in
any namespace block.

I don't see the setting you referred to. It's a Web site, not a project. I
can only assume that has something to do with why it didn't automatically
include a namespace in my new class - ???

You're right, VS2005 doesn't add a default namespace when you use the
website model. One more argument for the Web Application Project
template in my opinion.

Greetings,
Laurent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top