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