c# - Class in a list -
i understand in c# class passed reference. mean when store said class in list stored reference well, or better said c# style "pointer" of sorts? mean list n elements of class not take memory n times size of class n times size of reference class?
or thinking wrong?
you're right.
if create n elements of class t, , class t uses, say, 10 bytes, takes on order of 10*n memory.
if store in list<t>
, still have 10*n memory objects, plus n times size of c# reference , list
overhead. if store same elements in 2 lists, have 10*n objects, plus 2*n references, , 2 times list overhead. they're pointing @ same underlying objects.
Comments
Post a Comment