O'Reilly C# 5.0 in a Nutshell, 5th Edition 9781449320102 用户手册
产品代码
9781449320102
1
Introducing C# and the .NET
Framework
C# is a general-purpose, type-safe, object-oriented programming language. The goal
of the language is programmer productivity. To this end, the language balances
simplicity, expressiveness, and performance. The chief architect of the language
since its first version is Anders Hejlsberg (creator of Turbo Pascal and architect of
Delphi). The C# language is platform-neutral, but it was written to work well with
the Microsoft .NET Framework.
of the language is programmer productivity. To this end, the language balances
simplicity, expressiveness, and performance. The chief architect of the language
since its first version is Anders Hejlsberg (creator of Turbo Pascal and architect of
Delphi). The C# language is platform-neutral, but it was written to work well with
the Microsoft .NET Framework.
Object Orientation
C# is a rich implementation of the object-orientation paradigm, which includes
encapsulation, inheritance, and polymorphism. Encapsulation means creating a
boundary around an object, to separate its external (public) behavior from its internal
(private) implementation details. The distinctive features of C# from an
object-oriented perspective are:
encapsulation, inheritance, and polymorphism. Encapsulation means creating a
boundary around an object, to separate its external (public) behavior from its internal
(private) implementation details. The distinctive features of C# from an
object-oriented perspective are:
Unified type system
The fundamental building block in C# is an encapsulated unit of data and
functions called a type. C# has a unified type system, where all types ultimately
share a common base type. This means that all types, whether they represent
business objects or are primitive types such as numbers, share the same basic
set of functionality. For example, an instance of any type can be converted to a
string by calling its
functions called a type. C# has a unified type system, where all types ultimately
share a common base type. This means that all types, whether they represent
business objects or are primitive types such as numbers, share the same basic
set of functionality. For example, an instance of any type can be converted to a
string by calling its
ToString
method.
Classes and interfaces
In a traditional object-oriented paradigm, the only kind of type is a class. In C#,
there are several other kinds of types, one of which is an interface. An interface
is like a class, except that it only describes members. The implementation for
those members comes from types that implement the interface. Interfaces are
particularly useful in scenarios where multiple inheritance is required (unlike
there are several other kinds of types, one of which is an interface. An interface
is like a class, except that it only describes members. The implementation for
those members comes from types that implement the interface. Interfaces are
particularly useful in scenarios where multiple inheritance is required (unlike
1