Chapter 14

C# Language Enhancements


  • How to use initializers
  • What the var type is and how to use type inference
  • How to use anonymous types
  • What the dynamic type is and how to use it
  • How to use named and optional method parameters
  • How to use extension methods
  • What lambda expressions are and how to use them
  • How to use caller information attributes


You can find the code downloads for this chapter at on the Download Code tab. The code is in the Chapter 14 download and individually named according to the names throughout the chapter.

The C# language is not static. Anders Hejlsberg (the inventor of C#) and others at Microsoft continue to update and refine the language. At the time of this writing, the most recent changes are part of version 5 of the C# language, which is released as part of the Visual Studio 2012 product line, along with .NET 4.5. At this point in the book, you might be wondering what else could be needed; indeed, previous versions of C# lack little in terms of functionality. However, this doesn’t mean that it isn’t possible to make some aspects of C# programming easier, or that the relationships between C# and other technologies can’t be streamlined.

Perhaps the best way to understand this is to consider an addition that was made between versions 1.0 and 2.0 of the language — generics. You could argue that while generics are extremely useful, ...

Get Beginning Visual C# 2012 Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.