12 lines
664 B
Plaintext
12 lines
664 B
Plaintext
== How to fix it
|
|
|
|
`Contains` is a method defined on the `ICollection<T>` interface and takes a `T item` argument.
|
|
`Any` is an extension method defined on the `IEnumerable<T>` interface and takes a predicate argument.
|
|
Therefore, calls with simple equality checks like `Any(x => x == item)` can be replaced by `Contains(item)`.
|
|
|
|
This applies to the following collection types:
|
|
|
|
* https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1[HashSet<T>]
|
|
* https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.sortedset-1[SortedSet<T>]
|
|
* https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1[List<T>]
|