Link to home
Start Free TrialLog in
Avatar of tampsystems
tampsystemsFlag for United States of America

asked on

collection in the .net framework

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)
        {
            this.List.Add(obj);

        }
        public void Remove(PhoneNumber obj)
        {
            this.List.Remove(obj);
        }
    }

    public class PhoneCollection : List<PhoneNumber>
    {
    }
Avatar of alex_paven
alex_paven
Flag of Romania image

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.
Avatar of tampsystems

ASKER

what is a good reason to use the non-generic version?
ASKER CERTIFIED SOLUTION
Avatar of alex_paven
alex_paven
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial