Why would this compile:
public Dictionary<ValueLineType,
Func<HtmlHelper,
string,
object,
Type,
string>> constructor =
new Dictionary<ValueLineType,
Func<HtmlHelper,
string,
object,
Type,
string>>();
but not this other one with one extra parameter in the Func (the boolean):
public Dictionary<ValueLineType,
Func<HtmlHelper,
string,
object,
Type,
bool,
string>> constructor =
new Dictionary<ValueLineType,
Func<HtmlHelper,
string,
object,
Type,
bool,
string>>();
Either I'm getting blind or there's something else I'm going to learn today :D
There is no such thing as Func<T1,T2,T3,T4,T5,TResult>
. It only goes as far as 4 parameters (i.e. 5 type parameters, including one for the return value):
Func<T>
Func<T1, TResult>
Func<T1, T2, TResult>
Func<T1, T2, T3, TResult>
Func<T1, T2, T3, T4, TResult>
SpinalTap<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>
You can declare your own, of course:
public delegate TResult Func<T1, T2, T3, T4, T5, TResult>
(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);
However, at that point I'd think really carefully about whether you might be able to encapsulate some of those parameters together. Are they completely unrelated?
FYI, the next version of the .NET libraries will include Func and Action generic types of more than four parameters.
There are different classes defined by the framework named Func that take from 1 to 5 parameters. You'd need to define your own class that takes 6.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With