Alex Rivera | Logout

Action delegate with more than four parameters (method arguments)

Asked 2009-09-11T11:57:01.680
16

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

Edit
Report

1 Answer

26

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);
answered 2009-09-11T11:58:15.297

Your Answer