Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- namespace EvidenceCenter.NativeSQLiteParsing.Extensions
- {
- public static class LinqCollectionExtensions
- {
- public static bool Any<TSource>(this TSource[] source)
- => source.Length > 0;
- public static TSource Last<TSource>(this TSource[] source)
- => source[source.Length - 1];
- public static TSource LastOrDefault<TSource>(this TSource[] source)
- {
- var length = source.Length;
- return length == 0 ? default(TSource) : source[length - 1];
- }
- public static TSource First<TSource>(this TSource[] source)
- => source[0];
- public static TSource FirstOrDefault<TSource>(this TSource[] source)
- => source.Length == 0 ? default(TSource) : source[0];
- public static int Count<TSource>(this TSource[] source)
- => source.Length;
- public static bool Any<TSource>(this ICollection<TSource> source)
- => source.Count > 0;
- public static TSource Last<TSource>(this IList<TSource> source)
- => source[source.Count - 1];
- public static TSource LastOrDefault<TSource>(this IList<TSource> source)
- {
- var count = source.Count;
- return count == 0 ? default(TSource) : source[count - 1];
- }
- public static TSource First<TSource>(this IList<TSource> source)
- => source[0];
- public static TSource FirstOrDefault<TSource>(this IList<TSource> source)
- => source.Count == 0 ? default(TSource) : source[0];
- public static int Count<TSource>(this ICollection<TSource> source)
- => source.Count;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement