The difference between length and count in C # (personal view)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.