Arrays are fixed. Size, they are always initialized by determining the size of the advance.
.Length makes sense here because it is fixed, there are no operations to know this (don't think that not)
Versus .Count, on the other hand, implies that size is dynamic, and there is an operation (counting) to find out the size
.Length Collection List?
, ,
Enumerable, Enumerable Enumerator
, , ,
.Count(), System.Linq
public static int Count<TSource>(this IEnumerable<TSource> source)
{
if (source == null)
{
throw Error.ArgumentNull("source");
}
ICollection<TSource> is2 = source as ICollection<TSource>;
if (is2 != null)
{
return is2.Count;
}
int num = 0;
using (IEnumerator<TSource> enumerator = source.GetEnumerator())
{
while (enumerator.MoveNext())
{
num++;
}
}
return num;
}