Set/extend List length in c#

后端 未结 3 1249
广开言路
广开言路 2020-12-16 19:34

Given a List in c# is there a way to extend it (within its capacity) and set the new elements to null? I\'d like something that works like

3条回答
  •  别那么骄傲
    2020-12-16 20:22

    Why do you want to do that ? The main advantage of a List is that it can grow as needed, so why do you want to add a number of null or default elements to it ?

    Isn't it better that you use an array in this case ?

提交回复
热议问题