Datasheet

File system and registry access (see Chapter 24, “Manipulating Files and the Registry”)
Networking and Web browsing (see Chapter 35, “Accessing the Internet”)
.NET attributes and reflection (see Chapter 12, “Reflection”)
Access to aspects of the Windows OS (environment variables and so on; see Chapter 19, “.NET
Security”)
COM interoperability (see Chapters 38, “Enterprise Services” and 23, “COM Interoperability”)
Incidentally, according to Microsoft sources, a large proportion of the .NET base classes have actually
been written in C#!
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 are automatically 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#.
21
Chapter 1: .NET Architecture
24727c01.qxd:WroxPro 5/7/07 12:12 PM Page 21