I'm trying to determine when it's more efficient to List<T>.Add()
versus using the Array.Resize()
method.
The documentation for Array.Resize says it makes a copy of the entire array, and places it into a new object. The old object would have to be discarded. Where does this old object reside? On the stack or the heap?
I don't know how List.Add() works.
Does anyone know how the List.Add method compares to the static Array.Resize method?
I'm interested in memory usage (and cleanup), and what is better for 300 value types, versus 20,000 value types.
For what it's worth, I'm planning on running this code on one of the embedded flavors of .NET. Potentially the .NET Gadgeteer
List<T>
exists for a reason; use it! – Tamratamsky