Re: Boxing and Unboxing ??
- From: "Peter Olcott" <NoSpam@xxxxxxxxxxxxx>
- Date: Fri, 12 Jan 2007 17:28:11 -0600
"Bob Graham" <rvgrahamsevateneinKnowSpam@xxxxxxxxxxxxx> wrote in message
news:dec80702c6234c8cb8bf1774e777a67f@xxxxxxxxxxxxxx
Value types are stored on the "Stack" and go away, as it were, immediately
when they go out of scope. Mostly numeric types and structs.
Reference types are stored on the "Heap" and are garbage collected when
the system feels like it. References to ref types are passed normally as
a pointer to the address. Value types are passed a copy of the value.
I'm sure someone with more years under their Microsoft belt will chime
in here with a more exlicit and concise answer, but this is basically how
it is.
Bob
What I am looking for is all of the extra steps that form what is referred to as
boxing and unboxing. In C/C++ converting a value type to a reference type is a
very simple operation and I don't think that there are any runtime steps at all.
All the steps are done at compile time. Likewise for converting a reference type
to a value type.
in C/C++
int X = 56;
int *Y = &X;
Now both X and *Y hold 56, and Y is a reference to X;
According to Troelsen in "C# and the .NET Platform"
"Boxing can be formally defined as the process of explicitly converting
a value type into a corresponding reference type."
I think that my biggest problem with this process is that the terms
"value type"
and "reference type" mean something entirely different than what they
mean on every other platform in every other language. Normally a value
type is the actual data itself stored in memory, (such as an integer)
and a reference type is simply the address of this data.
It seems that .NET has made at least one of these two terms mean
something entirely different. can someone please give me a quick
overview of what the terms "value type" and "reference type" actually
mean in terms of their underlying architecture?
Posted by NewsLook (Trial Licence) from
http://www.ghytred.com/NewsLook/about.aspx
.
- Follow-Ups:
- Re: Boxing and Unboxing ??
- From: Arne Vajhøj
- Re: Boxing and Unboxing ??
- From: Mark R. Dawson
- Re: Boxing and Unboxing ??
- From: Bob Graham
- Re: Boxing and Unboxing ??
- From: Bob Graham
- Re: Boxing and Unboxing ??
- References:
- Boxing and Unboxing ??
- From: Peter Olcott
- Re: Boxing and Unboxing ??
- From: Bob Graham
- Boxing and Unboxing ??
- Prev by Date: Re: Retrieve Values from a ListBox
- Next by Date: Re: Boxing and Unboxing ??
- Previous by thread: Re: Boxing and Unboxing ??
- Next by thread: Re: Boxing and Unboxing ??
- Index(es):
Relevant Pages
|
Loading