This can be done intelligently, without lambda, using some common classes and helper functions. I used this approach in some vb.net/vs2005 code. If the goal is to give MethodInvoker, which calls a function with three arguments of types T, U and V, then create a class ParamInvoker <T, U, V> that contains the fields param1, param2 and param3 (like types T, U and V) and Action ( of type Action <T, U, V>) and has a DoIt (void) method that calls Action (param1, param2, param3). Common classes and helper functions are repeated, but the syntax is pretty good. For example (vb syntax, from memory and C # syntax, divination):
TheMethodInvoker = MakeParamInvoker (AddressOf MyFunction, 5, "Hello")
or
TheMethodInvoker = MakeParamInvoker (MyFunction, 5, "Hello")
Assuming MyFunction takes an integer and a string.
source share