Monday, December 2, 2013

How to make parameter Action a to be generic to accept for all kinds of function

"my purpose is to pass any function to a forloop"


That can only be done efficiently by providing multiple overloads of Forloop as shown in my example.


Otherwise you could use Delegate instead of Action and then use reflection to call its Invoke method with the required number of parameters.


Personally I'd consider changing the design so that instead of "any function" you use functions which take a single int array. Then you could simply use Action<int[]>.


As for threading, well, I don't really know what you're trying to do with this Forloop thing so I can't make a recommendation. And judging from previous posts of yours I'm not sure you have the necessary experience to do this.


No comments:

Post a Comment