Hi,
I have a problem Im hoping someone can help me with.
Ive
a control which extends the asp.net Calendar Control allowing me to
display lists of events on the calendar. Currently its datasource is a
Datatable.
I have several classes which represent different
types of events. The base Class is called CalendarEvent and is
exntended by MeetingEvent, ConferenceEvent, InterviewEvent etc.
I
have an interface ICalendarEvent which has one method, getDataTable,
which return a datatable in the right format for the Extended Calendar
control. My Event classes all implement this interface.
I want
to create a collection of objects which implement ICalendarEvent. This
List should be able to contain objects of type CalendarEvent,
MeetingEvent etc.
Is this possible?
Thanks,
Conor
Collection of objects of multiple types which implement an interface.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

AlanRank #669 · 3.6K reputationPosted May 2, 2008, 12:56 PM EDT
If you're using .NET 2.0 or later, just use a List. This works in much the same way as an ArrayList except that all the elements must be of types which implement ICalendarEvent.
Here's a link to the online docs for the generic List class if you're not familiar with it:
http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx
Conor3 reputationPosted May 2, 2008, 12:59 PM EDT