Re: Boxing and Unboxing ??




"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





.



Relevant Pages

  • Re: Boxing and Unboxing ??
    ... They get rid of boxing and unboxing penalties. ... In C/C converting a value type to ... reference type to a value type. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Boxing and Unboxing ??
    ... 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. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Boxing and Unboxing ??
    ... Likewise for converting a reference type ... According to Troelsen in "C# and the .NET Platform" ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: 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. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Boxing and Unboxing ??
    ... In C/C++ converting a value type to a reference type ... All the steps are done at compile time. ...
    (microsoft.public.dotnet.languages.csharp)

Loading