Dynamic Typing
Starting with .NET 4.0, C# supports dynamic typing. Variables typed as dynamic are used in a late-bound fashion, meaning that operations applied to them are resolved at runtime rather than at compile time. This is useful when dealing with an object that cannot be typed statically in a comfortable manner. Samples include Extensible Markup Language (XML) documents without an XML Schema Definition (XSD) schema or objects from dynamic languages such as Python, Ruby, or JavaScript.
Other than the built-in types discussed so far, no direct mapping exists between the C# reserved word dynamic and an underlying BCL type. Instead, dynamic is a special alias for System.Object, but with some additional metadata sprinkled on top of it to tell ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access