Chapter 14

C# Language Enhancements

WHAT YOU WILL LEARN IN THIS CHAPTER

  • 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

WROX.COM CODE DOWNLOADS FOR THIS CHAPTER

You can find the wrox.com code downloads for this chapter at www.wrox.com/remtitle.cgi?isbn=9781118314418 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 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.