Вход на сайт
C# - pattern matching - many discards
22611 просмотров
Перейти к просмотру всей ветки
в ответ alex445 08.03.24 16:43
https://github.com/dotnet/runtime/blob/main/src/libraries/...
Так это имелось в виду?
public static TSource First<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) { TSource? first = source.TryGetFirst(predicate, out bool found); if (!found) { ThrowHelper.ThrowNoMatchException(); } return first!; }