Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 441 Bytes

File metadata and controls

25 lines (18 loc) · 441 Bytes

GCop 640

"Write it as foo.Contains(VALUE)"

Rule description

The someCollection.Contains(...) method takes an object while Any(...) takes a predicate. So if you want to check for existence of an element, use Contains(...) rather than comparing every item using Any(...).

Example

if(foo.Any(fo => fo == bar))
{
    ...
}

should be 🡻

if(foo.Contains(fo => fo == bar))
{
    ...
}