比方说,我想存储一组函数指针在名单≤(* FUNC)>
,再后来打电话给他们,甚至与参数.. 。就像如果我存储在字典≤(* FUNC),对象[] PARAMS>
我可以打电话与参数FUNC?我将如何做到这一点?
Let's say I want to store a group of function pointers in a List<(*func)>
, and then later call them, perhaps even with parameters... Like if I stored in a Dict<(*func), object[] params>
could I call the func with the parameters? How would I do this?
.NET使用委托而不是函数指针。您可以将委托实例像任何其他类型的对象,在字典中或以其他方式。
.NET uses delegates instead of function pointers. You can store a delegate instance like any other kind of object, in a dictionary or otherwise.
请参阅从MSDN上的C#编程指南代表。
See Delegates from the C# Programming Guide on MSDN.