This book is about the language of C#. That often means going into some details of the runtime responsible for executing your code and the libraries that support your application, but the focus is firmly on the language itself.
The goal of the book is to make you as comfortable as possible with C# so you never need to feel you’re fighting against it. I want to help you feel you are fluent in C#, with the associated connotations of working in a fluid and flowing way. Think of C# as a river in which you’re paddling a kayak. The better you know the river, the faster you’ll be able to travel with its flow. Occasionally, you’ll want to paddle upstream for some reason; even then, knowing how the river moves will make it easier to reach your target without capsizing.
If you’re an existing C# programmer who wants to know more about the language, this book is for you! You don’t need to be an expert to read this book, but I assume you know the basics of C# 1. I explain all the terminology I use that was introduced after C# 1 and some older terms that are often misunderstood (such as parameters and arguments), but I assume you know what a class is, what an object is, and so on.
If you are an expert already, you may still find the book useful because it provides different ways of thinking about concepts that are already familiar to you. You may also discover areas of the language you were unaware of; I know that’s been my experience in writing the book.
If you’re completely new to C#, this book may not be useful to you yet. There are a lot of introductory books and online tutorials on C#. Once you have a grip on the basics, I hope you’ll return here and dive deeper.
This book comprises 15 chapters divided into 4 parts. Part 1 provides a brief history of the language.
Part 2 describes C# versions 2 through 5. This is effectively a rewritten and condensed form of the third edition of this book.
Part 3 describes C# 6 in detail.
Part 4 addresses C# 7 (all the way up to C# 7.3) and completes the book by peering a short distance into the future.
Finally, the appendix provides a handy reference for which features were introduced in which version of C# and whether they have runtime or framework requirements that restrict the contexts in which you can use them.
My expectation is that this book will be read in a linear fashion (at least the first time). Later chapters build on earlier ones, and you may have a hard time if you try to read them out of order. After you’ve read the book once, however, it makes perfect sense to use it as a reference. You might go back to a topic when you need a reminder of some syntax or if you find yourself caring more about a specific detail than you did on your first reading.
This book contains many examples of source code in numbered listings and in line with normal text. In both cases, source code is formatted in a fixed-width font like this to separate it from ordinary text. Sometimes it appears in bold to highlight code that has changed from previous steps in the chapter, such as when a new feature adds to an existing line of code.
In many cases, the original source code has been reformatted; I’ve added line breaks and reworked indentation to accommodate the available page space in the book. In rare cases, listings include line-continuation markers (). In addition, comments in the source code have often been removed from the listings when the code is described in the text. Code annotations accompany many of the listings and highlight important concepts.
Source code for the examples in this book is available for download from the publisher’s website at www.manning.com/books/c-sharp-in-depth-fourth-edition. You’ll need the .NET Core SDK (version 2.1.300 or higher) installed to build the examples. A few examples require the Windows desktop .NET framework (where Windows Forms or COM is involved), but most are portable via .NET Core. Although I used Visual Studio 2017 (Community Edition) to develop the examples, they should be fine under Visual Studio Code as well.
Purchase of C# in Depth, Fourth Edition, includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the author and from other users. To access the forum, go to https://forums.manning.com/forums/c-sharp-in-depth-fourth-edition. You can also learn more about Manning’s forums and the rules of conduct at https://forums.manning.com/forums/about.
Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the author can take place. It is not a commitment to any specific amount of participation on the part of the author, whose contribution to the forum remains voluntary (and unpaid). We suggest you try asking the author some challenging questions lest his interest stray! The forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.
There are many, many resources for C# online. The ones I find most useful are listed below, but you’ll find a lot more by searching, too.