A First Look at Dynamic Typing

image Starting with C# 4.0, late-bound access to members is also available through dynamic typing. In such a case, the compiler has no idea about the existence of the selected members. This kind of behavior is desirable in various scenarios:

• Objects may be totally typeless because they come from some dynamic language like Ruby or Python.

• Data representations may not have a schema, like with XML documents with no corresponding XSD schema.

• You received some object back using the static System.Object type but have no more specific type in reach to cast it to.

Historically, interacting with “loosely typed” objects from ...

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