There's no semantic difference for that specific example because:
Where(method)
will expect method
to have a signature bool method(T object)
where T
is the type of the enumerable, and it will just call method()
for each object in the sequence.
Where( item => method(item) )
does exactly the same thing, because it passes each object in the sequence to method()
.
However, if you need to (for example) use some property within item
to do the test, you then must use the explicit lambda.
For example, imagine if item
had a Text
property that you wanted to pass to method()
you'd have to do:
Where( item => method(item.Text) )
In this case, method()
would have the signature bool method(string)
.
More Details
The reason that you can just use the name of a method instead of a lambda delegate is because of "Method Group Conversions".
This is covered in detail in section 6.6 of the C# language spec. To simplify, what it means is that if a method has the same signature as a delegate, it can be automatically converted to such a delegate type.
From the spec:
An implicit conversion (§6.1) exists from a method group (§7.1) to a compatible delegate type. Given a delegate type D and an expression E that is classified as a method group, an implicit conversion exists from E to D if E contains at least one method that is applicable in its normal form (§7.5.3.1) to an argument list constructed by use of the parameter types and modifiers of D, as described in the following.
(And then it goes on in much more detail, which I won't post here!)