I have these classes:
public static class A{
...
public C Run<T>(string something)
{
...
}
}
public static class B{
...
public void Exec<T>(Type type)
{
MethodInfo method = typeof(A).GetMethod("Run");
MethodInfo generic = method.MakeGenericMethod(type);
var result = generic.Invoke(null, new object[] { "just a string" });
// bad call in next line
result.DoSomething();
}
}
public class C{
...
public void DoSomething(){}
}
How to convert result to type for call DoSomething method? And how simpler to call generic method using type variable?