Reputation: 6450
in order to determine my class type on Run-time i am using dynamic
:
dynamic dynamic = new MyClass();
dynamic.SomeMethod();
So this work fine and all good, the problem is that if i want to reach this object property
and in this case it seems that this is not possible:
dynamic.MyProperty;
Error 1 Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
Any solution ?
Upvotes: 0
Views: 32
Reputation: 7706
dynamic.MyProperty;
Is not a statement you can't use it in this way. Instead you can do something like this:
var abc = dynamic.MyProperty;
Upvotes: 1