I can define a delegate and write the query like this.
Func<string, bool> filter = s => s.Length == 5;
IEnumerable<string> query = names.Where(filter)
.Select(x => x.ToUpper());
My question is, if the Func<T, TResult> is a delegate taking a string as argument and returning a bool, why cannot I say:
delegate bool D(string s);
D d = new D(delegate(string s) { return s.Length == 1; });
IEnumerable<string> query = names.Where(d).Select...
?
Because they are different types.
A shorter version giving the same kind of error:
And the extension method
Whereis defined asSo you need a
Func<string, bool>andDis similar but not compatible.