13 Replies
you tell us
List<T> length is zero when created
the capacity of a list is not the same as its size
That argument you are passing is capacity, not actual length
List<int> arr = new List<int>(size);
doesnt it say "create list with this size
"
ohhhh
forgot those exist
so i need to pushback them 1 by 1?
is there more efficient solution?
sounds slow..it's already efficient if you keep parameter in constructor
so thats the way?
It's efficient because List prepared some memory for
size
elements when constructor is called, but just didn't use it until Add
is calledso i should have that (size) at the end of the list?
You can drop it, but it will be less efficient
okie
thanks men!
!close
Closed!