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

Posted on 2006-05-09
Last Modified: 2011-04-14
As question title, and if the auto boxing is used is there any alternative generic collection classes support value type without boxing?
Question by:teltel
    LVL 11

    Accepted Solution

    thats what generics are boxing and unboxing inside.
    you could use the List<T> for valuetypes.
    its completely typesave.
    LVL 19

    Assisted Solution

    by:Daniel Van Der Werken
    Here's some additional information:

    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
    LVL 13

    Assisted Solution

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now