C# 3.0 compatibility on .Net 2.0

后端 未结 2 1161
执笔经年
执笔经年 2021-01-13 22:14

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 <

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-13 22:35

    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).

提交回复
热议问题