collection in the .net framework

Posted on 2009-04-24
Last Modified: 2013-11-08
We would like to know the best practices for using collection in the .net framework.  We have the following two collections, what are the pros and cons for each.  One is a non generic collection and one is generic colleciton.  Would it be best pracices to use the generic colleciton all the time?

    public class PhoneCollection : CollectionBase
        public void Add(PhoneNumber obj)

        public void Remove(PhoneNumber obj)

    public class PhoneCollection : List<PhoneNumber>
Question by:tampsystems
    LVL 6

    Expert Comment

    The generic versions of collections tend to be more flexible and quite likely faster than using Objects, but it all depends on your specific requirements, of course.
    If you are interested in performance and type safety, I'd recommend the generic version.

    Author Comment

    what is a good reason to use the non-generic version?
    LVL 6

    Accepted Solution

    Ummm... actually I can't think of any really good ones. I suppose you'd be forced to not use generics if you target version 1.1 of the framework... or if you want to stuff anything in a collection and use crazy reflection logic to manipulate the objects...

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 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

    19 Experts available now in Live!

    Get 1:1 Help Now