Reputation: 109
I have the following issue :
I am using dynamic object ( ExpandoObject ) , whose properties I want to change runtime. What is the clue ... I want my properties to be doubles , because the user control , which I am using can not identify that the property is double if it's type is not double. As I know there is known type of the properties of the dynamic objects which should be double in the case , but it does not works for this control. So is there any explicit way , when I declare new property of the dynamic object to tell that it is double ?
Thanks in advance, Yoan
Upvotes: 0
Views: 1854
Reputation: 1063774
In the case of ExpandoObject
, just assign a double:
dynamic obj = new ExpandoObject();
obj.Foo = 123.45;
Console.WriteLine(obj.Foo.GetType()); // System.Double
However, I would say that a dynamic
object is probably not a good choice for UI binding (to a user-control), since they don't have a strong property model. In fact, most UI bindings aren't even up-to-date with dynamic
, and will be trying to use System.ComponentModel
(which doesn't know about dynamic
).
Upvotes: 1