Datasheet
Namespaces
Namespaces are the way that .NET avoids name clashes between classes. They are designed to avoid the
situation in which you define a class to represent a customer, name your class
Customer, and then
someone else does the same thing (a likely scenario — the proportion of businesses that have customers
seems to be quite high).
A namespace is no more than a grouping of data types, but it has the effect that the names of all data types
within a namespace automatically get prefixed with the name of the namespace. It is also possible to
nest namespaces within each other. For example, most of the general-purpose .NET base classes are in a
namespace called
System. The base class Array is in this namespace, so its full name is System.Array.
.NET requires all types to be defined in a namespace; for example, you could place your
Customer class
in a namespace called
YourCompanyName. This class would have the full name
YourCompanyName.Customer.
If a namespace is not explicitly supplied, the type will be added to a nameless global namespace.
Microsoft recommends that for most purposes you supply at least two nested namespace names: the
first one refers to the name of your company, and the second one refers to the name of the technology or
software package that the class is a member of, such as
YourCompanyName.SalesServices.Customer.
This protects, in most situations, the classes in your application from possible name clashes with classes
written by other organizations.
Chapter 2, “C# Basics,” looks more closely at namespaces.
Creating .NET Applications Using C#
C# can also be used to create console applications: text-only applications that run in a DOS window.
You’ll probably use console applications when unit testing class libraries, and for creating Unix or Linux
daemon processes. However, more often you’ll use C# to create applications that use many of the tech-
nologies associated with .NET. This section gives you an overview of the different types of applications
that you can write in C#.
Creating ASP.NET Applications
Active Server Pages (ASP) is a Microsoft technology for creating Web pages with dynamic content. An
ASP page is basically an HTML file with embedded chunks of server-side VBScript or JavaScript. When
a client browser requests an ASP page, the Web server delivers the HTML portions of the page, process-
ing the server-side scripts as it comes to them. Often these scripts query a database for data, and mark
up that data in HTML. ASP is an easy way for clients to build browser-based applications.
However, ASP is not without its shortcomings. First, ASP pages sometimes render slowly because the
server-side code is interpreted instead of compiled. Second, ASP files can be difficult to maintain
because they were unstructured; the server-side ASP code and plain HTML are all jumbled up together.
Third, ASP sometimes makes development difficult because there is little support for error handling and
21
.NET Architecture
05_575341 ch01.qxd 10/4/05 7:03 PM Page 21