C# in Depth cover

Author: Jon Skeet
Publisher: Manning
Published: 2008
Pages: 392

It took me a long time to get around to reading this book. Likely because I was coding almost exclusively in VB.NET, and only somewhat using C#. I have recently been using C# more and more, and finally got around to reading this book to see what the hype was about. I am glad I did – it is very educational!

I will back up a bit, to the hype comment. When C# first appeared, it made ripples in the development world. Since then, the language has gone through two upgrades – v2, then v3 – with noticeable improvements each time. Each release has been greeted with enthusiasm from .NET developers, thanks to the very useful improvements being made. The improvements, along with how they worked, how they were to be used, and how they fit in with C# on a greater scale, could be mysterious to the uninitiated. It was confusing. It was scary.

Then this book,C# in Depth, came along and made its own ripples. Once again, the .NET development community was pleased.

C# in Depth is literally that: an in-depth exploration of the C# language and how it was made better with each version. This book clears away the mystery and teaches the reader about how to get the most out of the language when writing code.

The book is divided in three main sections; the first discusses some of the capabilities of C# 1, along with the pain points. One in particular that stood out was the ArrayList, a common mechanism for dynamic lists of elements before generics arrived in C# v2. The boxing and unboxing of types in such containers was troublesome, to put it mildly.

The second section focuses on C# 2, and discusses additions such as generics (which I personally think is the single biggest improvement for C# 2), nullable types, the null coalescing operator, anonymous methods, and iterators. I also appreciate being able to write a property where the setter can have a different access level than the getter.

The final section looks at C# 3. The coverage is fairly broad, touching on auto properties, object/collection initializers, implicitly typed variables, anonymous types, lambda expressions, expression trees, and extension methods. The section finishes with two chapters dedicated to LINQ. Jon points out that LINQ is the single biggest feature of C# 3, and the various other improvements discussed previously lead up to making LINQ work.

LINQ gets a good amount of coverage. One chapter is spent looking at LINQ to Objects, which is essentially “standard” LINQ, working with objects in memory. Another chapter is spent presenting other LINQ providers, such as LINQ to XML, LINQ to Dataset, and LINQ to NHibernate. It goes to show that applications of LINQ are not limited to what comes with .NET, and that it is possible to create custom LINQ providers to provide access to various data sources.

A final chapter concludes the book. Jon ruminates on the evolution of C#, and provides opinions on where the language may expand in the future.

There is a single appendix that describes each LINQ operator in some detail, including examples. This provides more reference-type information than was given in the previous chapters covering LINQ.

C# in Depth is a exactly what it says: it covers the C# language in depth I had not experienced before. I now have a much better understanding of C#’s past and present capabilities than ever before, and know how to write code to take full advantage of all it has to offer. The book is not very heavy physically, but content-wise it weighs like a ton of bricks. I plan to re-read the book in the near future to ensure I have gotten the most I can from it. Some parts of it are pretty heady.

Jon is very concise, and explains important details without any fuss. Given that, this book is not ideal for a brand-new C# user, but rather for those that have used the language already. There is no discussion of the .NET framework here, except where it particularly ties in to the language. There is no introductory detail here: this is an in-depth reference book on the C# language – it is not a tutorial. Which is fine by me.

The book has its own page on the Manning site, but Jon also maintains a site dedicated to the book alone. It contains information about the book, revews, errata, and additional notes on content which did not get printed. The book’s accompanying source code can be downloaded here as well, along with Snippy, the tool Jon created to execute C# code samples.

Incidentally, Jon is making preparations for a second edition of this book, updated for C# 4. There has been some discussion on the subject on his website, regarding what material should be added, and what should be removed. It looks like there will certainly be new content to match up with C# 4 and .NET 4, and content on older C# versions will be selectively trimmed. There is already an early-access page for the book on the Manning website. I know the book will be worth getting when it is available.

The bottom line: at the end of it,C# in Depth is a book that will greatly increase your understanding and appreciation of the C# language. If you use C#, I suggest this book should be required reading.