It appears, the new "dynamic" object let's you create properties on the fly:
dynamic v = new object();
v.x = "a";
v.y = "b";
...
I am wondering if there is an easy way to programatically create properties. For example, let's say my properties are stored in a list as follows:
Tuple<string, string>[] list = new Tuple<string, string>[] {
new Tuple<string, string>("x", "a"),
new Tuple<string, string>("y", "b"),
};
I would like to iterate through this list and achieve the same result as we did earlier.
dynamic v = new object();
foreach (Tuple<string, string> keyValue in list) {
// somehow create a property on v that is named keyValue.Item1 and has a value KeyValue.Item2
}
I am wondering if this is even possible.
Objecttype doesn't so it won't work in this case.