Possible Duplicate:
count vs length vs size in a collection
In .NET, pretty much all collections have the .Count property.
Sometimes I wonder if it would be better to have it on Array as well, directly though, not through ICollection.
It's just something you make an exception in your mind only for arrays.
So is it better to be "more correct" or "more uniform" in this case?
Lengthincorrectly will throw an error because it either isn't available or it returned the wrong type of data. In PowerShell,CountandLengthproduce the same result for arrays, but collection objects don't return the expected result forLength. For example,([ordered]@{'a' = 0; 'bc' = 0;'def' = 0;}).Keys.Lengthreturns1,2,3and not3. This is becauseLengthreturns a list ofLengthproperties for each key, which is the length of each string.