public static TSource FirstOrDefault <TSource>(this IReadOnlyList <TSource> source, Func <TSource, bool> predicate) { switch (source) { case TSource[] array: return(ArrayExtensions.FirstOrDefault <TSource>(array, predicate)); default: return(ReadOnlyList.FirstOrDefault <IReadOnlyList <TSource>, IEnumerator <TSource>, TSource>(source, predicate)); } }
public static TSource FirstOrDefault <TSource>(this List <TSource> source) => ReadOnlyList.FirstOrDefault <List <TSource>, TSource>(source);