Chapter 8. Cutting fluff with a smart compiler

This chapter covers

  • Automatically implemented properties
  • Implicitly typed local variables
  • Object and collection initializers
  • Implicitly typed arrays
  • Anonymous types

We’ll start looking at C# 3 in the same way that we finished looking at C# 2—with a collection of relatively simple features. These are just the first small steps on the path to LINQ. Each of them can be used outside that context, but almost all are important for simplifying code to the extent that LINQ requires in order to be effective.

One important point to note is that although two of the biggest features of C# 2—generics and nullable types—required CLR changes, there were no significant changes to the CLR that shipped with ...

Get C# in Depth, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.