可能重複:
How to use reflection to call generic Method?
Select Right Generic Method with Reflection反思:如何得到一個通用的方法?
您好
比方說,我有一個類中的兩個以下兩種方法:
public void MyMethod(object val) {}
public void MyMethod<T>(T val) {}
與反思,我能得到這樣的第一種方法:
Type[] typeArray = new Type[1];
typeArray.SetValue(typeof(object), 1);
var myMethod = myInstance.GetType().GetMethod("MyMethod", typeArray);
但我怎麼能拿到第二,通用的方法是什麼?
可能重複的:http://stackoverflow.com/questions/ 3631547/select-right-generic-method-with-reflection – 2011-03-07 10:19:41
@AakashM:這*不是*特定問題的重複。 – LukeH 2011-03-07 10:28:53
@LukeH你是對的。不過,我敢打賭這是重複的東西。 – AakashM 2011-03-07 10:31:06