C# namespace vs. vb.net

  • Thread starter Thread starter Jeff Jarrell
  • Start date Start date
J

Jeff Jarrell

Correct me if I am wrong but doesn't C# handle the "root namespace" on the
project properties differently than vb.net?

In vb.net, I have setting the root namespace on the project properties.
Then for the most part I don't need an explicit namespace in each class. If
I do specify a namespace, then the root namespace is prepended to the
explicit one specified in the class.

Seems like in C#, if I am explicit in the file that is the namespace I get.
I don't seem where the root namespace on the project properties comes into
play. Yet I can't blank it out.

comments.

Thanks,
jeff
 
Jeff Jarrell said:
Correct me if I am wrong but doesn't C# handle the "root namespace" on the
project properties differently than vb.net?

In vb.net, I have setting the root namespace on the project properties.
Then for the most part I don't need an explicit namespace in each class. If
I do specify a namespace, then the root namespace is prepended to the
explicit one specified in the class.

Seems like in C#, if I am explicit in the file that is the namespace I get.
I don't seem where the root namespace on the project properties comes into
play. Yet I can't blank it out.

comments.

Yes, in C# the source file has all the information in that's required.
Personally, I like that - there's no "hidden" information needed to
know what's going on.
 
The only way that the 'default namespace' comes into play in C# is that the
designer will automatically insert that into new classes you create. It
doesn't have the 'hidden' behavior that the 'root namespace' has in VB.

It's kind of unfortunate that it's called "root namespace" in the .csproj
file, but in Visual Studio it's called 'default namespace' which is more
accurate.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
 
you are probably right. It wasn't readily apparent what vb was doing to me,
at least when I first started using namespaces.

thanks,
jeff
 
Jon Skeet said:
Yes, in C# the source file has all the information in that's required.
Personally, I like that - there's no "hidden" information needed to
know what's going on.

And in VS2005 you can use the Rename refactoring to change it easily.

PS
 
David Anton said:
The only way that the 'default namespace' comes into play in C# is that
the
designer will automatically insert that into new classes you create. It

It's also used for classes the build process creates (for embedded
resources, etc).
 
Back
Top