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
scroll top