I have a dynamic variable in which I store an object, which can be of several types, depending on the context (here Foo and Bar)
dynamic myvar;
myvar = new Foo();
myvar = new Bar();
Foo and Bar contain various methods. To access myvar methods, I thought you could use roles like
(Foo)myvar.mymethodoffoo();
(Bar)myvar.mymethodofbar();
But it does not work, I get (dynamic expression), this operation will be allowed at runtime in the code editor.
So, how can I create a dynamic object to get the available methods and properties from the editor?
Thanks in advance.
source
share