.net - Thumbrule on which collections have the Length or Count property - C# -


some c# collections have count , of them have length property. there thumbrule find out 1 has , why discrepency?

i'd general thumbrule following:

  • count collections variable length, i.e. lists (from icollection)
  • length fixed length collections, i.e. arrays, or other immutable objects, i.e. string.

update:

just elaborate count comes through icollection , doesn't indicate variability, example (as per greg beech's comment) readonlycollection<t> has count property not variable, implement icollection.

perhaps more exact rule of thumb be:

  • count indicates implements icollection
  • length indicates immutability.

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -