First of all, I know I can just define two overloaded helper methods to do what I need (or even just define two Func<>s with different names), but these are only used by one public method, so I'm exploring ways to define two local Func<>s that also overload by using the same name. Take, for example:
string DisplayValue(int value)
{ return DisplayValue(value, val => val.ToString()); }
string DisplayValue(int value, Func<int, string> formatter)
{ return (value < 0) ? "N/A" : formatter(value); }
I need to call one or the other version many times in my public method to custom format special values, so I thought I could "translate" the above into something like this:
Func<int, Func<int, string>, string> displayValue =
(value, formatter) => (value < 0) ? "N/A" : formatter(value);
Func<int, string> displayValue =
value => displayValue(value, val => val.ToString());
Even as I was typing it I knew I couldn't declare two delegate identifiers having the same name, even if they are different types. This is more academic than me being dead set on achieving overloads using Func<>s, but I guess they just can't do everything, right?
And I guess you can't do something like this, either:
Func<string, params object[], string> formatArgs =
(format, args) => string.Format(format, args);