rspec/rules/S6602/why-dotnet.adoc

9 lines
742 B
Plaintext

== Why is this an issue?
Both the `List.Find` method and `IEnumerable.FirstOrDefault` method can be used to find the first element that satisfies a given condition in a collection. However, `List.Find` can be faster than `IEnumerable.FirstOrDefault` for `List` objects. For small collections, the performance difference may be minor, but for large collections, it can make a noticeable difference. The same applies for `ImmutableList` and arrays too.
*Applies to*
* https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1.find[List]
* https://learn.microsoft.com/en-us/dotnet/api/system.array.find[Array]
* https://learn.microsoft.com/en-us/dotnet/api/system.collections.immutable.immutablelist-1.find[ImmutableList]