Giftsana

Giftsana

  • NA
  • 14
  • 0

Problem with ArrayList storing objects of different class type in c#

Feb 22 2006 9:23 PM

I have an ArrayList that has objects of different class types stored in it. Basically each of thess class represent a different Questionnaire class.

I retrieve each of these Questionnaire class with it's specific info like 'Question ID', 'Question text', 'Number of Choices' etc. and store it in an ArrayList say arrQDetails.

Now i want to iterate through each of the question objects in the ArrayList and perform respective implementations in each object i.e dynamically generating checkboxes based on 'Number of Choice'.

i am using foreach(Object o in objQuestionnaire.arrQDetails) . but it doesnt seem to work?if there are 2 objects(each have different details) of the same class type, i am able to dynamically generate controls only for one object type not the second object?

The arraylist may also have more than 1 object of the same type type but each with different info. there are 4 different class type of objects that am storing.

How do i solve this?

Awaiting a response soon. Thanks in advance.


Answers (2)