Press ENTER to search everything

Enumerable.​Count[TSource](IEnumerable`1) Method

Summary

Code

public static int Count<TSource>(IEnumerable<TSource> source)
{
    if (source == null)
    {
        throw Error.ArgumentNull("source");
    }
    ICollection<TSource> collection = source as ICollection<TSource>;
    if (collection != null)
    {
        return collection.get_Count();
    }
    ICollection collection2 = source as ICollection;
    if (collection2 != null)
    {
        return collection2.get_Count();
    }
    int i = 0;
    using (IEnumerator<TSource> enumerator = source.GetEnumerator())
    {
        while (enumerator.MoveNext())
        {
            i++;
            continue;
        }
    }
    return i;
}