LINQ and the features that made it possible: lambdas, extension methods, var and anonymous types.
This release added 10 features, each with a before-and-after example.
Features in C# 3.0
- Anonymous types - Create objects without explicitly defining a type.
- Auto implemented properties - Declare properties without explicit backing fields.
- Collection initializers - Populate collections inline during construction.
- Expression trees - Represent code as data structures for analysis or transformation.
- Extension methods - Add methods to existing types without modifying them.
- Implicitly typed local variables - Declare variables with
varso the compiler infers the type. - Lambda expressions - Create inline functions using concise
=>arrow syntax. - Object initializers - Set property values when creating an object.
- Partial methods - Define a method signature in a partial class for implementation elsewhere.
- Query expressions - Provide a native query syntax reminiscent of SQL.