More Effective C#
304 pages
English
PDF
4.5

More Effective C#

More Effective C#

Author:

Year:

Summary:

Introduction

The book More Effective C# (Bill Wagner, 2017) is a follow-up to the iconic guide Effective C#, aimed at developers who have already mastered the basics of the language and want to move to the next level. Unlike many textbooks, this book doesn't teach syntax — it teaches the mindset of a professional C# programmer. The author, a recognized expert in .NET and a member of the C# development team, shares 50 specific tips (items) that will help you write more reliable, performant, and maintainable code.

What the book is about

The book consists of 5 parts, each dedicated to a specific area of C# development:

  • Working with Types Fundamentals — how to properly design classes, structs, and interfaces, avoiding common mistakes.
  • Performance and Optimization — working with memory, garbage collection, asynchrony, and parallelism.
  • LINQ and Functional Programming — effective use of queries, lazy evaluation, and immutability.
  • Exceptions and Error Handling — how to build reliable systems using contracts and exceptions.
  • Modern C# Features (up to version 7.0) — tuples, local functions, pattern matching, and other features.

Each tip (item) is a self-contained section that can be read in any order. Wagner doesn't just list rules; he explains why you should do things one way and not another, backing up his arguments with code examples and references to the internal workings of .NET.

Who this book is for

The book is intended for experienced developers who have been writing C# for at least a year and have worked on real projects. Beginners will find it difficult — the author assumes knowledge of delegates, LINQ, asynchronous programming, and the basics of the CLR. However, if you feel your code has become "messy" or you want to understand how to avoid common performance pitfalls, this book will become your desktop reference.

What the reader will learn

  • How to properly choose between classes and structs, considering semantics and performance.
  • Why avoiding mutable structs is one of the main principles of reliable code.
  • How to effectively use async/await without blocking and deadlocks.
  • Secrets of working with LINQ: when to use deferred execution and when to use immediate execution.
  • How to write thread-safe code without excessive synchronization.
  • Why exceptions should not be part of the normal control flow.
  • How to use new C# 7.0 features (tuples, local functions, ref returns) to simplify code.
  • Methods of profiling and benchmarking for finding bottlenecks.

Strengths

Practical focus. Each tip is accompanied by real code that can be immediately applied in a project. The author doesn't give abstract advice — he shows how a specific construct affects performance or readability.

Deep understanding of the CLR. Wagner often looks "under the hood" of .NET, explaining how garbage collection, JIT compilation, and typing work. This helps make informed decisions rather than following patterns blindly.

Relevance. Despite the book being published in 2017, most of the tips remain relevant for C# 8, 9, and 10. The core principles (avoiding allocations, proper exception handling, effective use of LINQ) do not become outdated.

Structure. The book is convenient to use as a reference — you can open any section and get a complete recommendation. Each item ends with a brief summary.

Who it is recommended for

The book will be useful for:

  • Middle and Senior developers

Recommendations