[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

Is .NET 2.0 generic collection support value type with or without auto boxing and unboxing?

As question title, and if the auto boxing is used is there any alternative generic collection classes support value type without boxing?
0
teltel
Asked:
teltel
3 Solutions
 
vo1dCommented:
thats what generics are for.no boxing and unboxing inside.
you could use the List<T> for valuetypes.
its completely typesave.
0
 
Daniel Van Der WerkenIndependent ConsultantCommented:
Here's some additional information:

http://msdn2.microsoft.com/en-us/library/512aeb7t.aspx

Generics are a new feature in version 2.0 of the C# language and the common language runtime (CLR). Generics introduce to the .NET Framework the concept of type parameters, which make it possible to design classes and methods that defer the specification of one or more types until the class or method is declared and instantiated by client code. For example, by using a generic type parameter T you can write a single class that other client code can use without incurring the cost or risk of runtime casts or boxing operations, as shown here
0
 
devsolnsCommented:
Yes there is truly no boxing/unboxing in the .NET implementaion of generics.  Microsoft pulled it off correctly.

The same cannot be said for Java.  When you use generics in Java it is still boxing/unboxing primitive types and making everything an object for reference types.  Its smoke and mirrors with no runtime effieciency gained.

-gp
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now