Я искал сравнительный тест производительности между Contains
, Exists
и Any
методами, доступными в List<T>
. Я хотел найти это только из любопытства, так как меня всегда путали между ними. Многие вопросы о SO описывали определения этих методов, такие как:
- LINQ Ring: Any() vs Contains() для огромных коллекций
- Linq. Любой VS.Exists - В чем разница?
- Методы расширения LINQ - Any() vs. Where() vs. Exists()
Поэтому я решил сделать это сам. Я добавляю его в качестве ответа. Больше всего лучше понять результаты. Я также сделал этот бенчмаркинг для массивов, чтобы увидеть результаты