CHAPTER 1 THE PHILOSOPHY OF .NET
common types and programming constructs that all .NET programming languages can agree on. Thus, if
you build .NET types that expose only CLS-compliant features, you can rest assured that all .NET-aware
languages can consume them. Conversely, if you make use of a data type or programming construct that
is outside of the bounds of the CLS, you cannot guarantee that every .NET programming language can
interact with your .NET code library. Thankfully, as you will see later in this chapter, it is very simple to
tell your C# compiler to check all of your code for CLS compliance.
The Role of the Base Class Libraries
In addition to the CLR and CTS/CLS specifications, the .NET platform provides a base class library that is
available to all .NET programming languages. Not only does this base class library encapsulate various
primitives such as threads, file input/output (I/O), graphical rendering systems, and interaction with
various external hardware devices, but it also provides support for a number of services required by
most real-world applications.
The base class libraries define types that can be used to build any type of software application. For
example, you can use ASP.NET to build web sites, WCF to build networked services, WPF to build
desktop GUI applications, and so forth. As well, the base class libraries provide types to interact with
XML documents, the local directory and file system on a given computer, communicate with a relational
databases (via ADO.NET), and so forth. From a high level, you can visualize the relationship between the
CLR, CTS, CLS, and the base class library, as shown in Figure 1-1.
Figure 1-1. The CLR, CTS, CLS, and base class library relationship
What C# Brings to the Table
C# is a programming language whose core syntax looks very similar to the syntax of Java. However, to
call C# a Java clone is inaccurate. In reality, both C# and Java are members of the C family of
programming languages (e.g., C, Objective C, C++) and, therefore, share a similar syntax.
The truth of the matter is that many of C#’s syntactic constructs are modeled after various aspects of
Visual Basic (VB) and C++. For example, like VB, C# supports the notion of class properties (as opposed
to traditional getter and setter methods) and optional parameters. Like C++, C# allows you to overload
operators, as well as create structures, enumerations, and callback functions (via delegates).
5