Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# 3.0 compatibility on .Net 2.0

What are the C# 3.0 language features we can use in an application that targets .Net 2.0 framework ?

PS:I know few like Lambda expressions and var keyword

like image 956
Prashant Cholachagudda Avatar asked Jan 24 '23 05:01

Prashant Cholachagudda


1 Answers

I have an article on this very topic.

In brief:

Supported:

  • Automatically implemented properties, implicitly typed local variables and arrays, object and collection initializers, anonymous types, partial methods, lambda expressions converted into delegate types.

Partially supported:

  • Extension methods (requires an attribute) and query expressions (requires something like LINQBridge to be useful)

Not supported:

  • Lambdas converted into expression trees

In fact, I have heard that conversion into expression trees is available with the aid of Mono's implementation of System.Core. I haven't tried it yet though... I keep meaning to do so (and then update the page).

like image 109
Jon Skeet Avatar answered Jan 30 '23 09:01

Jon Skeet