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
Post a Comment