I think you should decide this based on the value semantics you want rather than where you think the data structure might be allocated, because that is really what is different between a
class
and a
struct
.
Yes, often it is the case that a
struct
is allocated on the stack but not always and it shouldn't be what dictates your design decision.
If you can show through relevant profiling that a one type of data structure gives you a performance increase (for example) then that might help you decide, but that should only be a consideration if performance is a proven problem.
My point is, stack or heap are not the important aspects of
class
es and
struct
s, the value semantics are.
This guy explains it a million times better than I can
http://blogs.msdn.com/b/ericlippert/archive/2010/09/30/the-truth-about-value-types.aspx[
^].
Hope this helps,
Fredrik