The Quick & Dirty .NET Guide to C#/VB OOP

Namespaces

.NET furthers the scope of OOP by compartmentalizing objects within namespaces, as an excellent means of categorizing and personalizing common and related fields, classes , structs or interfaces as a collection , as well as other namespaces known as nested namespaces! When including namespaces in an application, C# uses the " using " keyword to do that, whereas VB specifies " Imports " .

This is what facilitates and advances proper reusability and OOP practices. Devoid of this, you would have little structure. Creating a library of common class filled namespaces makes for a well-created application, always having modular components ready for use.

[C#]
namespace JimsEstate {
  public class House { ... }
  public class Car { ... }
  public class Garage { ... }
}

[VB]
Namespace JimsEstate
  ' Classes and other types of members go here
End Namespace

Here we have the namespace JimsEstate that contains a House, Car and Garage. All are neatly categorized together, and confusion in minimized, thus namespaces. Naming namespaces could easily extend beyond this. JimsEstate could be named JimsEstate.Land.NewYork.LongIsland, if you so choose. That's cool!

At any rate, we'll now look at one of the component types within - classes .

You might also like...

Comments

About the author

Dimitrios Markatos

Dimitrios Markatos United States

Dimitrios, or Jimmy as his friends call him, is a .NET developer/architect who specializes in Microsoft Technologies for creating high-performance and scalable data-driven enterprise Web and des...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.” - Donald Knuth