Re: Boxing and Unboxing ??




"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.com> wrote in
message news:upAgdrOOHHA.4172@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

"Peter Olcott" <NoSpam@xxxxxxxxxxxxx> wrote in message
news:ohWph.62189$9S6.3105@xxxxxxxxxxxxxxx
| So with Generics Boxing and UnBoxing beomes obsolete?

Not at all.

Generics simply offer the mechanisn for you not to be forced to use a
"cover all instances type" type when you declare a class. Before generics
you used to declare collections as storing objects. as you knew for sure
that EVERYTHING could be converted to an object reference (this imply boxing
with value types). This allowed you to write ONE ArrayList class and use it
with any kind of types.
Of course you could always write one for each value type plus one for
references type this would prevent boxing/unboxing

Now with generic you are taking the second approach one level further. It's
the compiler now who create that class for you at compile time.


But boxing/unboxing will still be there, forever and ever :)

I don't think so.




.



Relevant Pages

  • Re: Boxing and Unboxing ??
    ... and the only way to do that without boxing would be to ... Generics don't eliminate the need for, or usefulness of, boxing. ... the reflection methods to invoke a method dynamically ... Invoke(MethodInfo mi, A arg1, B arg2) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Boxing and Unboxing ??
    ... and the only way to do that without boxing would be to ... Generics don't eliminate the need for, or usefulness of, boxing. ... the reflection methods to invoke a method dynamically ... Invoke(MethodInfo mi, A arg1, B arg2) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Boxing and Unboxing ??
    ... | So with Generics Boxing and UnBoxing beomes obsolete? ... that EVERYTHING could be converted to an object reference (this imply boxing ... the compiler now who create that class for you at compile time. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: .NET anger.
    ... | pure WIN32 or .NET. ... Boxing maybe, but surely casting has 0 overhead? ... but these aren't generally anything to do with generics) ...
    (borland.public.delphi.non-technical)
  • Re: Java Generics and Erasure foobar
    ... I mean if I mix a String with an Integer this will come out in unit ... So one of the primary features of generics is this: ... Compile time safety is another vital feature. ... out in unit tests," but are you really that confident that every ...
    (comp.lang.java.programmer)

Loading