| |
| |
Figures | |
| |
| |
Tables | |
| |
| |
Foreword | |
| |
| |
Preface | |
| |
| |
Acknowledgments | |
| |
| |
About the Authors | |
| |
| |
| |
Introducing C# | |
| |
| |
Hello, World | |
| |
| |
C# Syntax Fundamentals | |
| |
| |
Console Input and Output | |
| |
| |
| |
Data Types | |
| |
| |
Fundamental Numeric Types | |
| |
| |
More Fundamental Types | |
| |
| |
null and void | |
| |
| |
Categories of Types | |
| |
| |
Nullable Modifier | |
| |
| |
Conversions between Data Types | |
| |
| |
Arrays | |
| |
| |
| |
Operators and Control Flow | |
| |
| |
Operators | |
| |
| |
Introducing Flow Control | |
| |
| |
Code Blocks ({}) | |
| |
| |
Code Blocks, Scopes, and Declaration Spaces | |
| |
| |
Boolean Expressions | |
| |
| |
Bitwise Operators (<<, >>, , &, �, �) | |
| |
| |
Control How Statements, Continued | |
| |
| |
Jump Statements | |
| |
| |
C# Preprocessor Directives | |
| |
| |
| |
Methods and Parameters | |
| |
| |
Calling a Method | |
| |
| |
Declaring a Method | |
| |
| |
The using Directive | |
| |
| |
Returns and Parameters on Main () | |
| |
| |
Advanced Method Parameters | |
| |
| |
Recursion | |
| |
| |
Method Overloading | |
| |
| |
Optional Parameters | |
| |
| |
Basic Error Handling with Exceptions | |
| |
| |
| |
Classes | |
| |
| |
Declaring and lnstantiating a Class | |
| |
| |
Instance Fields | |
| |
| |
Instance Methods | |
| |
| |
Using the this Keyword | |
| |
| |
Access Modifiers | |
| |
| |
Properties | |
| |
| |
Constructors | |
| |
| |
Static Members | |
| |
| |
Extension Methods | |
| |
| |
Encapsulating the Data | |
| |
| |
Nested Classes | |
| |
| |
Partial Classes | |
| |
| |
| |
Inheritance | |
| |
| |
Derivation | |
| |
| |
Overriding the Base Class | |
| |
| |
Abstract Classes | |
| |
| |
All Classes Derive from System Object | |
| |
| |
Verifying the Underlying Type with the is Operator | |
| |
| |
Conversion Using the as Operator | |
| |
| |
| |
Interfaces | |
| |
| |
Introducing Interfaces | |
| |
| |
Polymorphism through Interfaces | |
| |
| |
Interface Implementation | |
| |
| |
Converting between the Implementing Class and Its Interfaces | |
| |
| |
Interface Inheritance | |
| |
| |
Multiple Interface Inheritance | |
| |
| |
Extension Methods on Interfaces | |
| |
| |
Implementing Multiple Inheritance via Interfaces | |
| |
| |
Versioning | |
| |
| |
Interfaces Compared with Classes | |
| |
| |
Interfaces Compared with Attributes | |
| |
| |
| |
Value Types | |
| |
| |
Structs | |
| |
| |
Boxing | |
| |
| |
Enums | |
| |
| |
| |
Well-Formed Types | |
| |
| |
Overriding object Members | |
| |
| |
Operator Overloading | |
| |
| |
Referencing Other Assemblies | |
| |
| |
Defining Namespaces | |
| |
| |
XML Comments | |
| |
| |
Garbage Collection | |
| |
| |
Resource Cleanup | |
| |
| |
Lazy Initialization | |
| |
| |
| |
Exception Handling | |
| |
| |
Multiple Exception Types | |
| |
| |
Catching Exceptions | |
| |
| |
General Catch Block | |
| |
| |
Guidelines for Exception Handling | |
| |
| |
Defining Custom Exceptions | |
| |
| |
Wrapping an Exception and Rethrowing | |
| |
| |
| |
Generics | |
| |
| |
C# without Generics | |
| |
| |
Introducing Generic Types | |
| |
| |
Constraints | |
| |
| |
Generic Methods | |
| |
| |
Covariance and Contravariance | |
| |
| |
Generic Internals | |
| |
| |
| |
Delegates and Lambda Expressions | |
| |
| |
Introducing Delegates | |
| |
| |
Lambda Expressions | |
| |
| |
Anonymous Methods | |
| |
| |
General-Purpose Delegates: System.Func and System.Action | |
| |
| |
| |
Events | |
| |
| |
Coding the Observer Pattern with Multicast Delegates | |
| |
| |
Events | |
| |
| |
| |
Collection Interfaces with Standard Query Operators | |
| |
| |
Anonymous Types and Implicitly Typed Local Variables | |
| |
| |
Collection Initializers | |
| |
| |
What Makes a Class a Collection: IEnumerable<T> | |
| |
| |
Standard Query Operators | |
| |
| |
| |
LI NQ with Query Expressions | |
| |
| |
Introducing Query Expressions | |
| |
| |
Query Expressions Are Just Method Invocations | |
| |
| |
| |
Building Custom Collections | |
| |
| |
More Collection Interfaces | |
| |
| |
Primary Collection Classes | |
| |
| |
Providing an Indexer | |
| |
| |
Returning Null or an Empty Collection | |
| |
| |
Iterators | |
| |
| |
| |
Reflection, Attributes, and Dynamic Programming | |
| |
| |
Reflection | |
| |
| |
Attributes | |
| |
| |
Programming with Dynamic Objects | |
| |
| |
| |
Multithreading | |
| |
| |
Multithreading Basics | |
| |
| |
Working with System. Threading | |
| |
| |
Asynchronous Tasks | |
| |
| |
Canceling a Task | |
| |
| |
The Task-Based Asynchronous Pattern in C# 5.0 | |
| |
| |
Executing Loop Iterations in Parallel | |
| |
| |
Running LFNQ Queries in Parallel | |
| |
| |
| |
Thread Synchronization | |
| |
| |
Why Synchronization? | |
| |
| |
Timers | |
| |
| |
| |
Platform Interoperability and Unsafe Code | |
| |
| |
Using the Windows Runtime Libraries from C# | |
| |
| |
Platform Invoke | |
| |
| |
Pointers and Addresses | |
| |
| |
Executing Unsafe Code via a Delegate | |
| |
| |
| |
The Common Language Infrastructure | |
| |
| |
Defining the Common Language Infrastructure (CLI) | |
| |
| |
CLI Implementations | |
| |
| |
C# Compilation to Machine Code | |
| |
| |
Runtime | |
| |
| |
Application Domains | |
| |
| |
Assemblies, Manifests, and Modules | |
| |
| |
Common Intermediate Language (CIL) | |
| |
| |
Common Type System (CTS) | |
| |
| |
Common Language Specification (CLS) | |
| |
| |
Base Class Library (BCL) | |
| |
| |
Metadata | |
| |
| |
| |
Downloading and Installing the C# Compiler and CLI Platform | |
| |
| |
Microsoft's .NET | |
| |
| |
| |
Tic-Tac-Toe Source Code Listing | |
| |
| |
| |
Interfacing with Mutithreading Patterns Prior to the TPLandC#5.0 | |
| |
| |
Asynchronous Programming Model | |
| |
| |
Asynchronous Delegate Invocation | |
| |
| |
The Event-Based Asynchronous Pattern (EAP) | |
| |
| |
Background Worker Pattern | |
| |
| |
Dispatching to the Windows UI | |
| |
| |
| |
Timers Prior to the Async/Await Pattern of C# 5.0 | |
| |
| |
Index | |
| |
| |
Index of C# 5.0 Topics | |
| |
| |
Index of C# 4.0 Topics | |
| |
| |
Index ofC#3.0 Topics | |