Depends on the size of struct but for the example you gave structs will be
more efficient memory wise (some suggest under 12-16 bytes go for structs
and anything more use classes). However you will incur a boxing hit if you
use value types in an ArrayList so only by measuring the real scenario
yourself can you come up with an answer. If you know how many you'll have
beforehand, struct with normal arrays is the best solution in my view (until
we get generics in the next version).
Cheers
Daniel
--
http://www.danielmoth.com/Blog/
"Renzo" <(E-Mail Removed)> wrote in message
news:99B327D3-F1E3-4DAA-874E-(E-Mail Removed)...
> Hi, I use C# on Compact Framework for PPC program development. Well, I
> need
> to use many ArrayList() of data and I don't know which is the best memory
> management that I will have to use. Is more convenient to use a Class() or
> a
> Struct() to store my data? For example (with some sintax errorrs):
>
> class TPoint
> {
> int x;
> int y;
> }
> or
> struct TPoint
> {
> int x;
> int y;
> }
>
> ArrayList MyPoints=new ArrayList();
> PPoint=new TPoint();
> for (iLoop=1; iLoop<=1000; iLoop++)
> {
> TPoint PPoint=(TPoint) MyPoints[MyPoints.Add(new TPoint())];
> PPoint.x=iLoop;
> PPoint.y=iLoop;
> }
>
> I read that Class() are stored in the Heap, while Struct() are stored in
> the
> Stack memory. Well, which is the best way (for memory space, memory
> performance, etc...) to store my data in PPC memory where I have a little
> memory to manage?
> --
> Thanks in advance,
> Renzo Contarini