Default namespace confusion

S

shumaker

I'm confused about the default namespace setting in the project
properties. Help has the following:

"Default namespace
Specifies the base namespace for all files in the project. For example,
if you set the root namespace to Project1 and you have a Class1 outside
of any namespace in your code, its namespace would be Project1.Class1.
If you have a Class2 within a namespace Order in code, its namespace
would be Project1.Order.Class2."

This would imply if I have

namespace Foo{
class Bar{...}
}

And set my default namespace to "Grand", then I thought my class should
appear as Grand.Foo.Bar, but it seems to just be Foo.Bar

So I'm not at all sure now what the default namespace does.
 
G

Guest

The default namespace in C# does not have the same meaning as the VB default
namespace. In C#, all it means is that this namespace will be added by
default to new classes you create (i.e., the text "namespace Foo" will be
added to the file).

In VB, it means that everything in the project is implicitly within the
default namespace.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
C# Code Metrics: Quick metrics for C#
 

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

Top