A very basic auto-expanding list/array
Posted
by MainMa
on Stack Overflow
See other posts from Stack Overflow
or by MainMa
Published on 2010-03-25T14:59:38Z
Indexed on
2010/03/25
15:03 UTC
Read the original article
Hit count: 333
Hi,
I have a method which returns an array of fixed type objects (let's say MyObject
).
The method creates a new empty Stack<MyObject>
. Then, it does some work and pushes some number of MyObjects
to the end of the Stack
. Finally, it returns the Stack.ToArray()
.
It does not change already added items or their properties, nor remove them. The number of elements to add will cost performance. There is no need to sort/order the elements.
Is Stack a best thing to use? Or must I switch to Collection
or List
to ensure better performance and/or lower memory cost?
© Stack Overflow or respective owner