data structures - Preallocating List c# -


i working in c# , creating list (newlist) can length of list (otherlist). in c# list implemented in way preallocating length of list better performance using otherlist.count or use newlist.add(obj) , not worry length?

the following constructor list<t> implemented purpose of improving performance in scenarios yours:

http://msdn.microsoft.com/en-us/library/dw8e0z9z.aspx

public list(int capacity)

just pass capacity in constructor.

newlist = new list<string>(otherlist.count);


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -