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 ...
Get C# 5.0 Unleashed 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.