infuerno.github.io

Jon Skeet: C# In Depth 4th Edition

References

This book is dedicated to equality, which is significantly harder to achieve in the real world than overriding Equals()and GetHashCode().

Book website: https://csharpindepth.com Publishers website: https://www.manning.com/books/c-sharp-in-depth-fourth-edition

Part 1: C# in context

Chapter 1: Survival of the sharpest

A helpful type system

Statically typed languages help show intent in large programs.

Concise code

C#’s features allow you to reduce ceremony, remove boilerplate code, and avoid cruft.

Data access with LINQ

Asynchrony

Part 2: C# 2-5

Chapter 2: C# 2

C# 2 was released with Visual Studio 2005 and .NET 2.0. Important features were generics, better constructs for writing both delegates and iterators.

Generics

General purpose code which is type safe at compile time. Mainly used in collections, delegates (particularly LINQ), async code with Task<T> and nullable value types.

Generics has type parameters and type arguments, same idea but applied to types.

Nullable value types

A nullable type encapsulates the value and a flag. At the core is the public struct Nullable<T> : where T : struct struct.

With regards to the fact that trying to access the value of a nullable value type which doesn’t have a value will throw an exception:

I think it’s important enough to restate: progress doesn’t come just from making it easier to write correct code; it also comes from making it harder to write broken code or making the consequences less severe.

Simplified delegate creation

The basic purpose of delegates is to encapsulate a piece of code so that it can be passed around and executed as necessary in a type-safe fashion in terms of the return type and parameters.

StringProcessor proc = delegate(string input) { Console.Write($"{input}") }

Iterators