9

Possible Duplicate:
count vs length vs size in a collection

Am I overlooking a semantic difference between "Length" and "Count", or did perhaps some implementation detail in the .NET Framework require different names for these similar concepts? Given the close attention that was paid to naming and everything else in the framework, there must be a good explanation.

Community
  • 1
  • 1
  • This is a duplicate of [http://stackoverflow.com/questions/300522/count-vs-length-vs-size-in-a-collection/300540](http://stackoverflow.com/questions/300522/count-vs-length-vs-size-in-a-collection/300540) (You can find a good answer there, incl. other variations as well.) – Alex Jul 29 '09 at 07:23

1 Answers1

10

Actually these are similar but not identical concepts. Since an array's length is static and its memory gets allocated once and for all (int[] intarray = new int[10]; // allocates the memory for 10 ints) the Length property is quite static. Otherwise Enumerables like a List might not know their Length beforehand so the Property Count will in some way "count" the length (you might iterate through all associated elements in an enumerable). That's the basic difference.

Max
  • 1,078
  • 2
  • 9
  • 29