I am trying out a little reflection and have a question on how the cast the result object to an IList.
Here is the reflection:
private void LoadBars(Type barType)
{
// foo has a method that returns bars
Type foo = typeof(Foo);
MethodInfo method = foo.GetMethod("GetBars")
.MakeGenericMethod(bar);
object obj = method.Invoke(foo, new object[] { /* arguments here */ });
// how can we cast obj to an IList<Type> - barType
}
How can we cast the result of method.Invoke to an IList of Type from the barType argument?