What is a namespace? See Wikipedia.

For a company that builds its own software, namespaces are crucial to integrate applications. Maybe a stand-alone application that you’re building right now will one day be used as an external component. That’s why you need to use namespaces to identify your code.

VB.NET vs C#

A key difference between namespace in C# and VB.NET is the declaration. In VB.Net, the default namespace is prepended to every type and resource in your assembly when compiled. In C#, the default namespace is used as a guide for creating namespaces in code at design-time. Since in C#, namespaces must be explicitly declared, the Default Namespace is not prefixed to types or resources in your assembly.

Take a look at the following example. Let’s say that my default namespace on my project is “Be.MikeBevers.NamespaceTest”.

Namespace Foo
	Public Class FooTest
	End Class
End Namespace

Public Class Test
End Class
namespace Be.MikeBevers.NamespaceTest.Foo
	public class FooTest {}

namespace Be.MikeBevers.NamespaceTest
	public class Test {}

If you would compile the VB.NET code and the C# code, you would have the exact same dll.

How they did it

They didn’t.

All files were dropped in the main project directory, no subdirectories were used. Concrete example: In the UI project, both Forms and UserControls were located in the main directory.

Even worse, when I took a look at the project properties, the default namespace was “UI”.

How I do it

Imho, every project should have a valid, describing namespace. Especially in an enterprise environment, no matter how small the application is. So I’ve given a valid default namespace to all projects and reorganized the structure a bit per project.

Another thing about namespaces and VB.NET: when you don’t define a namespace, no matter in which subdirectory you reside, the default namespace will be used. So in every subdirectory you explicitly need to set the path that has to follow behind the default namespace. Fe: if the class resides in Forms/Dialogs, your namespace is Forms.Dialogs.