There are two overloads for Select() . One that takes as its second parameter (i.e., the Delegate) a Func<TSource, TResult> , and one that accepts Func<TSource, int, TResult> . That is, a method signature with one or two parameters.
Your method does not satisfy either one or the other. Even with default values, it still has three parameters. The default parameters are a compilation time construct and must be provided on the call site. They are not populated at run time by invoking the delegate instance.
So, in fact, your work is one of two reasonable ways to solve the problem. Another would be to implement the default settings in different ways (ie, "Old School" :)):
static int MethodWithDefaultParameters(int a) { return MethodWithDefaultParameters(a, 0, 1); } static int MethodWithDefaultParameters(int a, int b, int c) { return a + b + c; }
Then you can use MethodWithDefaultParameters in your Select() call directly, since the compiler will find a one-parameter overload compatible with one of the Select() overloads.
source share