Reputation: 1012
I have written a helper class which uses the Action - delegate as method parameter.
Like this:
public void SomeMethod(Action<T> methodToExecute, T argument);
According to the MSDN you can declare max. 4 arguments on an action delegate: Action<T1,T2,T3,T4>
.
Now I'd like to call a method which needs 5! arguments. How could I do this?
The best solution would be something where I could use a dynamic number of method arguments.
Thanks
Upvotes: 16
Views: 6400
Reputation: 391724
Declare the action delegate you need, there's nothing magic about it:
public delegate void Action<T1, T2, T3, T4, T5>(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5);
Upvotes: 26