Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想声明一个参数化的方法数组或方法列表。这意味着将有一个方法数组,我可以通过使用数组的索引来调用该方法,同时我想为该方法提供一个参数。我怎样才能做到这一点?
如果您知道方法签名,则可以执行以下操作:
使用接受int并返回 a的方法示例string:
int
string
var functionList = new List<Func<int, string>>(); functionlist.Add(SomeMethod) functionlist[0](12345); //call the function //Assuming you had this: public string SomeMethod(int val) { ...