Advertisement
Guest User

Untitled

a guest
Mar 20th, 2013
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1.     [__DynamicallyInvokable]
  2.     public static int Count<TSource>(this IEnumerable<TSource> source)
  3.     {
  4.       if (source == null)
  5.         throw Error.ArgumentNull("source");
  6.       ICollection<TSource> collection1 = source as ICollection<TSource>;
  7.       if (collection1 != null)
  8.         return collection1.Count;
  9.       ICollection collection2 = source as ICollection;
  10.       if (collection2 != null)
  11.         return collection2.Count;
  12.       int num = 0;
  13.       using (IEnumerator<TSource> enumerator = source.GetEnumerator())
  14.       {
  15.         while (enumerator.MoveNext())
  16.           checked { ++num; }
  17.       }
  18.       return num;
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement