This article will be very short ... Shorter than your JJ, of course, joking. Online has said length and count of the difference, are very vague, I did not find the article is more thorough, so, although this article is very short, I still hope to stay in the home, listen to everyone on the topic of the view, if you do not believe, you really do not find similar articles, anyway, I did not search.
Perhaps some of the views are wrong, or incorrect, and please point out that my point is:
- Length: The "number" of objects used to calculate the number of "objects" in a contiguous memory area, and the count () to compute a block of non-contiguous blocks of memory;
- Length is a unique property of this collection object, it inherits from System.object;count () is not a property, but a method, each time the iterator pointer points to the successor of this object (MoveNext () method), of course, you can also understand as a single linked list, So this is why the iterator cannot have subscript, because it can not jump to find an address, then its size is unknown.
- The size of the length is determined by the data type of the object set and the size defined by the initialization time;
- Some people think that there is an iterator, then the length, length is based on the iterator, which is wrong, then you may refute:. NET of the underlying data type, why can use foreach, then you well on the int above click F12, you will find, in fact: It is Int32 this object inside. Other words. NET does not exist in the so-called basic data types;
The difference between length and count in C # (personal view)