ExpandoObject as IDictionary<string, object>
Why is this important? It’s because the ExpandoObject implements the IDictionary<string, object> interface and therefore can be used with the ConvertToType methods!
Here’s what you do:
Pretty cool, eh? ;-)
But what if the shape of the expando object doesn’t match your type? E.g. there are properties defined on MyClass but not on the expando object, or vice versa, or both? Well, it’s smart enough to work that out itself and only set the properties which it is able to set:
Subscribe to my newsletter and get new contents delivered straight to your inbox :-)