Re: Boxing and Unboxing ??



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


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 ??
    ... 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 ... Likewise for converting a reference type ... According to Troelsen in "C# and the .NET Platform" ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Modifying a struct-based property
    ... > Structs are typically used when performance is an issue ... the thing to act like a _value_: like an int or a double or a decimal. ... a Measure is a quantity that has a unit of measure (a reference type, ... The garbage collector does not have to clean up the ...
    (microsoft.public.dotnet.csharp.general)
  • Re: slowness
    ... > all by value entities) are thread safe, which if its locking some mutex or ... There's nothing inherently thread-safe about structs. ... struct as shared data (as a member of a shared reference type object, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C#2.0: struct & class constraints
    ... >>> but have certain semantics of reference type, ... > many of the same functionality as classes, methods, etc because of ... > how .NET implements them (vs other languages which treat structs very ...
    (microsoft.public.dotnet.languages.csharp)

Loading