List<> Capacity returns more items than added

前端 未结 5 1608
北海茫月
北海茫月 2020-12-06 16:58

There are several properties on List that seem to be related to number of items in the list - Capacity, Count (which is prese

5条回答
  •  情歌与酒
    2020-12-06 17:29

    To add to the other answers, the default behaviour of List when adding items one by one is to start with a capacity of 4 and double it whenever the list becomes full. This explains the capacity of 8.

提交回复
热议问题