Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [__DynamicallyInvokable]
- public static int Count<TSource>(this IEnumerable<TSource> source)
- {
- if (source == null)
- throw Error.ArgumentNull("source");
- ICollection<TSource> collection1 = source as ICollection<TSource>;
- if (collection1 != null)
- return collection1.Count;
- ICollection collection2 = source as ICollection;
- if (collection2 != null)
- return collection2.Count;
- int num = 0;
- using (IEnumerator<TSource> enumerator = source.GetEnumerator())
- {
- while (enumerator.MoveNext())
- checked { ++num; }
- }
- return num;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement