C# 3.0 New Language Features (Part 1)

Introduction

Well, in this article I'll illustrate some of the C# 3.0 new language and compiler features and I'll illustrate the rest of the features in the second part. First of all, let's define all the new features:

Instead of using the explicit type, now we can use the inferred type which means declaring any local variable as var and the type will be inferred by the compiler from the expression on the right side of the initialization statement. This inferred type could be:

Sometimes you spend a lot of time writing a lot of redundant code to declare constructors that do the same job. Object initializers can be used to initialize types without writing explicit constructors.

Enables initialization of collections with an initialization list rather than specific calls to Add or another method. This initialization has the same effect as using the Add method with each collection element.

Comments and Discussions

Your article is very good summary of new C# features. However, try to credit and cite your sources. Many of your statements are EXACT extracts from MSDN C# Programming Guide (see my link below on Extension Methods). I suggest you add a section to your article and cite your sources. It only adds value to your work. Please join the fight againts plagiarism!