The ExpandoObject Class
Learn to use the ExpandoObject class to dynamically add properties and methods to an object at runtime.
We'll cover the following...
We'll cover the following...
A key feature of the DLR resides in the System.Dynamic namespace: the ExpandoObject class. This type lets us create dynamic objects that expand during program execution. For instance, we could add a method or some other member at runtime. The System.Dynamic namespace brings JavaScript-like capabilities to .NET.
Syntax
We instantiate the ExpandoObject class using the new keyword. We declare the variable using the dynamic keyword to utilize its runtime capabilities.
Here is a quick example of how we initialize it: