The C# 3.0 language and compiler introduce several new language features. These new language constructs are useful individually in various contexts, and collectively for doing Language-Integrated Query (LINQ). For more information about LINQ, see The LINQ Pro.
Note |
The September 2006 Community Technology Preview version of the C# compiler and Visual C# IDE do not fully implement or support the C# 3.0 language specification. Error messages and IntelliSense™ support, even for implemented language features, are not yet complete. Therefore, to create LINQ projects you should use the May 2006 LINQ which includes a prototype version of the new compiler. |
The following table lists the new C# 3.0 language features:
Feature |
Description |
Present in September 2006 CTP |
Implicitly Typed Local Variables (C# Programming Guide) |
When used with local variables, the var keyword instructs the compiler to infer the type of the variable from the expression on the right side of the initialization statement. |
Yes |
Object Initializers (C# Programming Guide) |
Enables object initialization without explicit calls to a constructor. |
Yes |
Collection Initializers (C# Programming Guide) |
Enables initialization of collections with an initialization list rather than specific calls to "Add" or another method. |
Partially |
Implicitly Typed Arrays (C# Programming Guide) |
Enables the type of the array instance to be inferred from the elements specified in the array initializer. |
No |
Extension Methods (C# Programming Guide) |
Extend existing classes with static methods that can be invoked by using instance method syntax. |
Partially |
Anonymous Types (C# Programming Guide) |
Enables on-the-fly creation of unnamed structured types that can be added to collections and accessed using var. |
No |
Lambdas (C# Programming Guide) |
Enables inline expressions with input parameters that can be bound to delegates or expression trees. |
Partially |
Query Keywords (C# Reference) |
Keywords that specify clauses in a query expression:
|
Partially |
ms-help://MS.MSDNQTR.v90.en/MS.MSDN.v90/MS.VisualStudio.v90.en/dv_cscon/html/e5193336-6adb-471e-ab22-e3fc60e0fa52.htm
以上文字来自 MSDN Library for Visual Studio Codename Orcas.
本想弄个实际一点的代码来着。后来想想水平有限,时间有限就别丢人了J