Why can't an anonymous method be assigned to var?
I have the following code: Func<string, bool> comparer = delegate(string value) { return value != "0"; }; However, the following does not compile: var comparer = delegate(string value) { return value != "0"; }; Why can't the compiler figure out it is a Func<string, bool> ? It takes one string parameter, and returns a boolean. Instead, it gives me the error: Cannot assign anonymous method to an implicitly-typed local variable. I have one guess and that is if the var version compiled , it would lack consistency if I had the following: var comparer = delegate(string arg1, string arg2, string arg3