I have created this dynamic object, and I want to access the properties by name:
dynamic obj = new ExpanadoObject();
obj.Name = "Reza";
What I want is
obj["Name"] = "Reza";
or
var name = obj["Name"];
How can I do that?
I have created this dynamic object, and I want to access the properties by name:
dynamic obj = new ExpanadoObject();
obj.Name = "Reza";
What I want is
obj["Name"] = "Reza";
or
var name = obj["Name"];
How can I do that?
TryGetValue is so handy provided by IDictionary
dynamic obj = new ExpandoObject();
IDictionary<string, object> dictionary = obj;
dictionary["Name"] = "Reza";
dict.TryGetValue("Name", out object name);