C# in Depth: Chapters 8 and 9 now in MEAP

I should have written this a little while ago, but it slipped my mind. Despite that, I think it’s pretty exciting for anyone who’s actually following along in the early access edition (and yes, such people do exist). The reason? These are the first C# 3 chapters. Here’s what they’ve got in them:

Chapter 8: Cutting fluff with a smart compiler

This is a bit like chapter 7, in that it’s a collection of small features. The difference between the two chapters is that the features in C# 3 mostly work together towards LINQ, so there’s more of an obvious connection between them. In this chapter we look at:

  • Automatically implemented properties (a.k.a. automatic properties)
  • Implicit typing of local variables (the “var” keyword – note that this is not dynamic typing)
  • Simplified initialization (object initializers, collection initializers)
  • Implicitly typed arrays
  • Anonymous types

Chapter 9: Lambda expressions and expression trees

If you have been following C# 3, you’ll know what these topics are – and if you don’t, I certainly can’t do them justice in a short blog post. In some senses, these are actually simple concepts: an easier way of creating a delegate instance, and a way of representing code as data, optionally using the same syntax. The implications of this are massive, though. We could have LINQ without anonymous types, even though it would be more painful. With that out of the way we wouldn’t really need implicitly typed local variables or arrays. But without expression trees and lambda expressions, LINQ would be dead in the water.

It takes more than just the concepts being there in the first place though. When was the last time you looked at the rules of type inference for generic methods? If your answer is “never” then you’re probably in the company of 99% of C# developers – and that’s perfectly reasonable, to be honest. However, the rules have changed for C# 3 to make them more powerful – to let the compiler do more work for us. The last part of chapter 9 deals with the changes. I should warn you, it’s not pretty – but it’s worth knowing that the rules are explained (with a little bit of hand waving) in a format which is slightly more user friendly than the specification.


So, that’s the most recent two chapters. The next to chapters to be released actually conclude the “strictly C#” part of the book, leaving just LINQ providers and the conclusion – we’re nearly there!

2 thoughts on “C# in Depth: Chapters 8 and 9 now in MEAP”

  1. Good to see you’re finally writing a book Jon, I’m a long time follower of the ‘yoda’ as you have come to be known round here.

    Why so long before a paperback copy?


  2. Nice to know it’s being anxiously awaited :)

    In terms of the time scale, the book isn’t “finished” yet. I’ve written all the chapters, but they’re still undergoing peer review, then there’s technical review, proof reading, production editing, indexing etc. That’s all before they go to the printers – then there’s the printing time itself, and transportation.

    Of course the MEAP edition cuts out a lot of this to get it into your hands earlier, but it means you’re more likely to find mistakes. (Hopefully not too many, mind you.) I suspect the final eBook will come out a bit before the print edition, but it will still be after all the reviewing etc.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s