Tuesday, July 7, 2009

C# 4.0's New Features Explained

Introduction

The Beta for Visual Studio 2010 is upon us and included is the CTP of C# 4.0. While C# 4.0 does not represent a radical departure from the previous version, there are some key features that should be understood thoroughly in order to take advantage of their true potential.

Background

The white paper for C# 4.0's features does a good job of explaining the changes in the language. I thought, however, that some larger code samples and historical perspective would help people (especially new developers) in understanding why things have changed.

Feature Categories

Microsoft breaks the new features into the following four categories so I will maintain the pattern.

  • Named and Optional Parameters
  • Dynamic Support
  • Variance
  • COM Interop

Conventions

Some of the examples assume the following classes are defined:


See full detail: http://www.codeproject.com/KB/cs/CSharp4Features.aspx

No comments: