Chapter 4. C# 4: Improving interoperability

This chapter covers
  • Using dynamic typing for interoperability and simpler reflection
  • Providing default values for parameters so the caller doesn’t need to specify them
  • Specifying names for arguments to make calls clearer
  • Coding against COM libraries in a more streamlined fashion
  • Converting between generic types with generic variance

C# 4 was an interesting release. The most dramatic change was the introduction of dynamic typing with the dynamic type. This feature makes C# statically typed (for most code) and dynamically typed (when using dynamic) in the same language. That’s rare within programming languages.

Dynamic typing was introduced for interoperability, but that’s turned ...

Get C# in Depth, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.