The Dot NET Framework Is Just a Huge Collection of Namespaces, As Explained by This Article

0
4

The.NET framework pops up everywhere in computing these days – whether you're creating a websites using ASP.NET or designing a report using SQL Server Reporting Services, chances are that you'll have to come across the .NET framework . But … what is it? The key to understanding.NET is to understand namespaces , and this is best done by reference to the biological classification system.

How Biologist Classify Life (This IS Relevant, Honest!)

Linnaeus (a biologist) classified life in the following hierarchy.

  • Kingdom
  • Phylum
  • Class
  • Order
  • Family
  • Genus
  • Species

Thus a human descendants to the Eukarya kingdom, Animalia phylum, Chordata class, Mammalia order, Primates family, Hominidae genus and Homo species. One way to understand this is to write it as:

Eukarya.Animalia.Chordata.Mammalia.Primates.Hominidae.Homo

The.NET Framework Works in the Same Way

Consider the color pink. This can be written in.NET as:

System.Drawing.Color.Pink

To put this another way, Pink belongs to the System kingdom, the Drawing phylum and the Color Class – except they're not called these things, but instead are called namespaces .

References and the IMPORTS Statement

Suppose that you want to color your textbox pink. A typical command to do this is:

me.txtBox.BackColor = System.Drawing.Color.Pink

Do you really have to type all this out every time that you want to color something? The answer is no, because you can reference the System.Drawing.Color namespace. To do this in Visual Basic, you would write:

Imports System.Drawing.Color

at the top of your code: that way, you could use objects in the Color namespace without qualifying them. For example:

me.txtBox.BackColor = Pink

Another Example – Creating a Text Reader

A command in Visual Basic to create a streamreader (something which reads in a text file) is:

DIM sr As New System.IO.StreamReader

However, because the StreamReader class belongs in the System.IO namespace, we could instead write this as:

IMPORTS System.IO

followed at some stage by

DIM sr As New StreamReader .

Conclusion

The.NET framework is really just a collection of classes (4000+ when I last looked) arranged in a sensible hierarchy.

Source

Leave a Reply