.net - How does System.Object store "objects" internally? -
i reading boxing, , book says "boxing can formally defined process of explicitly converting value type corresponding reference type storing variable in system.object
." (emphasis added)
my question isn't boxing, got me thinking - how , system.object instance store values/variables/objects assigned it. i'm wondering not only
object objshort = 5;
but also
object someotherobj = somereallycomplicatedobject;
i've been looking around, including here (msdn system.object), , don't see anywhere describes how system.object instance stores data.
is object storing pointer object assigned it, or in case of boxing, pointer @ value type on stack?
(jon, forgive me if in book too. have ordered , on way!)
that description of boxing inaccurate. object created isn't instance of bare system.object
; each value type has own "hidden" corresponding reference type class deriving valuetype
implementing same interfaces value type, , field of type of value type. that's how think of it, @ least, , it's how cli spec describes it. system.object
doesn't have storage this.
i'd want correct "storing variable" part - boxing stores value in object. value might value of variable, or result of method call, or whatever.
of course reference types, boxing isn't required @ all. need distinguish between reference , object though - once you've got 2 clear in mind, other things follow easily. remember value of variable never object - it's ever value type value or reference (or pointer :)
(oh, , covered somewhat in c# in depth, not in great detail. might interested in eric lippert's post "the truth value types" though.)
Comments
Post a Comment