How to cast returned value of CreateInstance
-
30-10-2019 - |
Question
How does one cast the return value from CreateInstance when the type is unknown?
For example in this code:
MethodInfo mInfo = typeof(MyType).GetMethod(MethodBase.GetCurrentMethod().Name);
Object o = Activator.CreateInstance(mInfo.ReturnType);
how do I cast my o to whatever mInfo.ReturnType contains?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow