如何使用反射来调用此方法。
using System.Reflection
public static string NotSoObvius<V>(V show) where V : class
{
return string.Format("This is it", show);
}
答案 0 :(得分:-1)
你应该尝试这样的事情:
Type myType = Type.GetType("MyClass");
MethodInfo notSoObviusInfo = myType.GetMethod("NotSoObvius");
Type[] types = new Type[]{typeof(YourDesiredTypeHere)};
notSoObviusInfo = notSoObviusInfo.MakeGenericMethod(types);
string myReturn = (string)notSoObviusInfo.Invoke(null, new[]{new YourDesiredTypeHere()});
来自:https://msdn.microsoft.com/pt-br/library/a89hcwhh(v=vs.110).aspx