collection class inheritance
First
of all I am very new to c#. I am in a class, and I am dealing with a
project where I have to keep track of many items that are similar using
a collection class. The dilema arises that there are 2 types of items
but they are very similar. I would like (I am almost sure this is
possible) to have one collection class that is inherited by 2 different
collection classes. I want to add the items using the child class.
Based on the object type I am trying to add, it should be able to hold
the proper information. I know I have done similar things using form
inheriteance.
DavePosted Jun 29, 2008, 2:52 AM
However, two things you could try -:
-1- as you said, tailor a couple of classes to inherit from a parent class. You may want to use IComparable members in the parent class to keep things generic;
-2- rather than using inheritance, just use 2 generic collections e.g. a generic list.