Introduction

内容以《C#高级编程》为索引,《C#编程指南》、《C#语言规范》等官方文档为参考。

Chapter 1: .NET Applications and Tools

Chapter 2: Core C#

FUNDAMENTALS OF C#

WORKING WITH VARIABLES

USING PREDEFINED DATA TYPES

CONTROLLING PROGRAM FLOW

GETTING ORGANIZED WITH NAMESPACES

UNDERSTANDING THE MAIN METHOD

USING COMMENTS

UNDERSTANDING C# PREPROCESSOR DIRECTIVES

这部分内容建议跳过,以后用到再补。

C# PROGRAMMING GUIDELINES

Chapter 3: Objects and Types

CLASSES AND STRUCTS

CLASSES

STRUCTS

PASSING PARAMETERS BY VALUE AND BY REFERENCE

NULLABLE TYPES

ENUM TYPES

PARTIAL CLASSES

EXTENSION METHODS

Chapter 4: Object-Oriented Programming with C#

OBJECT ORIENTATION

The three most important concepts of object-orientation are inheritance, encapsulation, and polymorphism.

封装、继承、多态是面向对象的编程的三个主要特征。

INHERITANCE

MODIFIERS

INTERFACES

IS AND AS OPERATORS

Chapter 5: Generics

GENERICS OVERVIEW

CREATING GENERIC CLASSES

GENERICS FEATURES

Default Values

Constraints

Inheritance

Static Members

Static members of generic classes are shared with only one instantiation of the class, and they require special attention. Consider the following example, where the class StaticDemo<T> contains the static field x:

public class StaticDemo<T>
{
        public static int x;
}

Because the class StaticDemo<T> is used with both a string type and an int type, two sets of static fields exist:

StaticDemo<string>.x = 4;
StaticDemo<int>.x = 5;
Console.WriteLine(StaticDemo<string>.x); // writes 4

泛型类是支持静态成员的,但官方不建议这么做。

GENERIC INTERFACES

Covariance and Contra-Variance

Covariance with Generic Interfaces

Contra-Variance with Generic Interfaces

GENERIC STRUCTS

Similar to classes, structs can be generic as well. They are very similar to generic classes with the exception of inheritance features.

泛型结构体除了无法继承,其他和泛型类相似。

书上关于 Nullable<T> 的代码运行失败,跳过这部分。

GENERIC METHODS

Chapter 6: Operators and Casts

OPERATORS

The checked and unchecked Operators

The is Operator

The as Operator

The sizeof Operator

The typeof Operator

The nameof Operator

The index Operator

Nullable Types and Operators

The Null Coalescing Operator

The Null-Conditional Operator

Operator Precedence and Associativity

USING BINARY OPERATORS

TYPE SAFETY

Type Conversions

Boxing and Unboxing

COMPARING OBJECTS FOR EQUALITY

OPERATOR OVERLOADING

IMPLEMENTING CUSTOM INDEX OPERATORS

USER-DEFINED CASTS

Chapter 7: Arrays

SIMPLE ARRAYS

MULTIDIMENSIONAL ARRAYS

JAGGED ARRAYS

RANGER

ARRAY CLASS

Copying Arrays

Shallow copy

Deep copy

If you need a deep copy of an array containing reference types, you have to iterate the array and create new objects.

ARRAYS AS PARAMETERS

ENUMERATORS

STRUCTURAL COMPARISON

SPANS

ARRAY POOLS

Chapter 8: Delegates, Lambdas, and Events

DELEGATES

Simple Delegate Example

Action and Func Delegates

Multicast Delegates

Anonymous Methods

LAMBDA EXPRESSIONS

EVENTS

Chapter 9: Strings and Regular Expressions

EXAMINING SYSTEM.STRING

STRING FORMATS

REGULAR EXPRESSIONS

STRINGS AND SPANS

高阶知识,暂时跳过。