The Class Declaration
Just to cover our bases, you already know that declaring a class and putting it in a particular namespace looks like Listing 2.1.
Listing 2.1. The basic class declaration
C#
VB.NET
namespace MyNamespace
{
public class Car
{
// class members
}
}
We use namespaces because the .NET Framework is strongly typed. That means we give every class a fully qualified name to make sure that it's not duplicated and that there's no confusion about the class we're referencing. For example, both ASP.NET and Windows Forms have a TextBox class. The framework knows the difference because one lives in the System.Web.UI.WebControls namespace and the other in the System.Windows.Forms.Control namespace. We don't need to use its fully qualified name because we make using (Imports in VB.NET) declarations at the top of our code files so the compiler knows what we're talking about.
Namespace MyNamespace
Public Class Car
' class members
End Class
End Namespace