[C #] How to create a dynamic object

Heitor Helmer Herzog
1 min readJan 30, 2017

--

Sometimes very typed languages ​​end up disrupting us rather than helping. Creating each property with its specific type inside a class for example, when would it be easier to simply do as you do with : object.newVariable= “hello”
Fortunately C # has a type that allows us to dynamically create objects when appropriate.
Just initialize the object with the class of type ExpandoObject and say that the variable is of type dynamic and ready.
See in Example:

--

--

Heitor Helmer Herzog
Heitor Helmer Herzog

Written by Heitor Helmer Herzog

Software developer, In love with games and the industry. Let’s code! About me: www.linkedin.com/in/heitorhherzog

No responses yet