Contents

Figures

Tables

Foreword

Preface

Acknowledgments

About the Author

1 Introducing C#

Hello, World

C# Syntax Fundamentals

Working with Variables

Console Input and Output

Managed Execution and the Common Language Infrastructure

Multiple .NET Frameworks

2 Data Types

Fundamental Numeric Types

More Fundamental Types

Conversions between Data Types

3 More with Data Types

Categories of Types

Declaring Types That Allow null

Implicitly Typed Local Variables

Tuples

Arrays

4 Operators and Flow Control

Operators

Introducing Flow Control

Code Blocks ({})

Code Blocks, Scopes, and Declaration Spaces

Boolean Expressions

Programming with null

Bitwise Operators (<<, >>, |, &, ^, ~)

Control Flow Statements, Continued

Jump Statements

C# Preprocessor Directives

Summary

5 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

Summary

6 Classes

Declaring and Instantiating a Class

Instance Fields

Instance Methods

Using the this Keyword

Access Modifiers

Properties

Constructors

Non-Nullable Reference Type Properties with Constructors

Nullable Attributes

Deconstructors

Static Members

Extension Methods

Encapsulating the Data

Nested Classes

Partial Classes

Summary

7 Inheritance

Derivation

Overriding the Base Class

Abstract Classes

All Classes Derive from System.Object

Pattern Matching with the is Operator

Pattern Matching within a switch Expression

Avoid Pattern Matching When Polymorphism Is Possible

Summary

8 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

Versioning

Extension Methods versus Default Interface Members

Interfaces Compared with Abstract Classes

Interfaces Compared with Attributes

9 Value Types

Structs

Boxing

Enums

Summary

10 Well-Formed Types

Overriding object Members

Operator Overloading

Referencing Other Assemblies

Encapsulation of Types

Defining Namespaces

XML Comments

Garbage Collection

Resource Cleanup

Lazy Initialization

Summary

11 Exception Handling

Multiple Exception Types

Catching Exceptions

Rethrowing an Existing Exception

General Catch Block

Guidelines for Exception Handling

Defining Custom Exceptions

Rethrowing a Wrapped Exception

Summary

12 Generics

C# without Generics

Introducing Generic Types

Constraints

Generic Methods

Covariance and Contravariance

Generic Internals

Summary

13 Delegates and Lambda Expressions

Introducing Delegates

Declaring Delegate Types

Lambda Expressions

Statement Lambdas

Anonymous Methods

Delegates Do Not Have Structural Equality

Outer Variables

Expression Trees

Summary

14 Events

Coding the Publish–Subscribe Pattern with Multicast Delegates

Understanding Events

Summary

15 Collection Interfaces with Standard Query Operators

Collection Initializers

What Makes a Class a Collection: IEnumerable

Standard Query Operators

Anonymous Types with LINQ

Summary

16 LINQ with Query Expressions

Introducing Query Expressions

Query Expressions Are Just Method Invocations

Summary

17 Building Custom Collections

More Collection Interfaces

Primary Collection Classes

Providing an Indexer

Returning null or an Empty Collection

Iterators

Summary

18 Reflection, Attributes, and Dynamic Programming

Reflection

nameof Operator

Attributes

Programming with Dynamic Objects

Summary

19 Introducing Multithreading

Multithreading Basics

Asynchronous Tasks

Canceling a Task

Working with System.Threading

Summary

20 Programming the Task-Based Asynchronous Pattern

Synchronously Invoking a High-Latency Operation

Asynchronously Invoking a High-Latency Operation Using the TPL

The Task-Based Asynchronous Pattern with async and await

Introducing Asynchronous Return of ValueTask<T>

Asynchronous Streams

IAsyncDisposable and the await using Declaration and Statement

Using LINQ with IAsyncEnumerable

Returning void from an Asynchronous Method

Asynchronous Lambdas and Local Functions

Task Schedulers and the Synchronization Context

async/await with the Windows UI

Summary

21 Iterating in Parallel

Executing Loop Iterations in Parallel

Running LINQ Queries in Parallel

Summary

22 Thread Synchronization

Why Synchronization?

Timers

Summary

23 Platform Interoperability and Unsafe Code

Platform Invoke

Pointers and Addresses

Executing Unsafe Code via a Delegate

Summary

24 The Common Language Infrastructure

Defining the Common Language Infrastructure

CLI Implementations

.NET Standard

Base Class Library

C# Compilation to Machine Code

Runtime

Assemblies, Manifests, and Modules

Common Intermediate Language

Common Type System

Common Language Specification

Metadata

.NET Native and Ahead of Time Compilation

Summary

Index

Index of 8.0 Topics

Index of 7.0 Topics

Index of 6.0 Topics

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.244.216