O'Reilly C# 5.0 in a Nutshell, 5th Edition 9781449320102 用户手册

产品代码
9781449320102
下载
页码 21
from explicitly deallocating the memory for an object, eliminating the problem of
incorrect pointers encountered in languages such as C++.
C# does not eliminate pointers: it merely makes them unnecessary for most pro-
gramming tasks. For performance-critical hotspots and interoperability, pointers
may be used, but they are permitted only in blocks that are explicitly marked unsafe.
Platform Support
C# is typically used for writing code that runs on Windows platforms. Although
Microsoft standardized the C# language through ECMA, the total amount of re-
sources (both inside and outside of Microsoft) dedicated to supporting C# on non-
Windows platforms is relatively small. This means that languages such as Java are
sensible choices when multiplatform support is of primary concern. Having said
this, C# can be used to write cross-platform code in the following scenarios:
• C# code may run on the server and dish up HTML that can run on any platform.
This is precisely the case for ASP.NET.
• C# code may run on a runtime other than the Microsoft Common Language
Runtime. The most notable example is the Mono project, which has its own
C# compiler and runtime, running on Linux, Solaris, Mac OS X, and Windows.
• C# code may run on a host that supports Microsoft Silverlight (supported for
Windows  and  Mac  OS  X).  This  technology  is  analogous  to  Adobe’s  Flash
Player.
C#’s Relationship with the CLR
C# depends on a runtime equipped with a host of features such as automatic mem-
ory management and exception handling. The design of C# closely maps to the
design of Microsoft’s Common Language Runtime (CLR), which provides these run-
time features (although C# is technically independent of the CLR). Furthermore,
the C# type system maps closely to the CLR type system (e.g., both share the same
definitions for predefined types).
The CLR and .NET Framework
The .NET Framework consists of the CLR plus a vast set of libraries. The libraries
consist of core libraries (which this book is concerned with) and applied libraries,
which depend on the core libraries. 
 is a visual overview of those libraries
(and also serves as a navigational aid to the book).
The CLR is the runtime for executing managed code. C# is one of several managed
languages
 that get compiled into managed code. Managed code is packaged into an 
assembly, in the form of either an executable file (an .exe) or a library (a .dll), along
with type information, or metadata.
Managed code is represented in Intermediate Language or IL. When the CLR loads
an assembly, it converts the IL into the native code of the machine, such as x86. This
The CLR and .NET Framework | 3
Introduction