The ExpandoObject Class
Create objects that can dynamically extend throughout the program execution.
We'll cover the following
Introduction
One of the most interesting features of the DLR resides in the System.Dynamic
namespace: the ExpandoObject
class. This type lets us create dynamic objects that can extend while the program is running. For instance, we could add a method or some other member at runtime. The System.Dynamic
namespace brings JavaScript-like capabilities to .NET.
Syntax
The ExpandoObject
class is instantiated just like any other type:
dynamic car = new ExpandoObject();
What makes it different from other classes is that we can define new members at runtime:
Get hands-on with 1400+ tech skills courses.