Dynamic binding, named and optional arguments, and generic variance.
This release added 6 features, each with a before-and-after example.
Features in C# 4.0
- Dynamic binding - Defer type checking until runtime using the dynamic keyword.
- Embedded interop types - Embed COM interop type information directly into assemblies.
- Generic contravariant - Mark a generic type parameter with
inso a less derived type argument can be used. - Generic covariant - Mark a generic type parameter with
outso a more derived type argument can be used. - Named arguments - Specify method parameters by name instead of position.
- Optional arguments - Define default values for method parameters to make them optional.