Reporter | P B (permb) |
---|---|
Created | Mar 23, 2012 4:21:43 PM |
Updated | Mar 23, 2012 4:32:08 PM |
Resolved | Mar 23, 2012 4:27:43 PM |
Priority | Normal |
Type | Feature |
Fix versions | No Fix versions |
State | Won't fix |
Assignee | Evgeny Pasynkov (pasynkov) |
Subsystem | No subsystem |
Affected versions | No Affected versions |
Fixed in build | No Fixed in build |
First will never return null - it throws an exception if the item cannot be found.
FirstOrDefault however may return null.
I have seen coworkers do:
var x = y.First(x => false);
if (x == null) {
...
}
and it would be valuable to hint to them that they are either using the wrong method (should be using FirstOrDefault) or writing dead code.
FirstOrDefault however may return null.
I have seen coworkers do:
var x = y.First(x => false);
if (x == null) {
...
}
and it would be valuable to hint to them that they are either using the wrong method (should be using FirstOrDefault) or writing dead code.