Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

OOA question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stephen  Cao - 27 Mar 2008 22:00 GMT
Hi all:

I have a base class SurveyObject, and I derive two new classes
Question and Instruction.

I then create an
ArrayList<SurveyObject> soList = new ArrayList();
and add Instructions and Questions to the ArrayList.
 Instruction i1 = new Instruction();
 soList.Add(i1);
 Question q1 = new Question();
 soList.Add(q1);
 Question q2 = new Question();
 soList.Add(q2);

I have a form1 to handle Instructions and a form2 to handle Questions.

What is most elegant way to select the approrpriate form to display
the appropriate SurveyObject when I loop through the ArrayList of
SurveyObjects?

Thanks,
Stephen
Simon Hart [MVP] - 27 Mar 2008 22:36 GMT
The cleaner solution is to have separate collections for each form. Note: You
can't add multiple types to a generic arraylist, you can with a non-generic
arraylist though.
Signature

Simon Hart
Visual Developer - Device Application Development MVP
http://simonrhart.blogspot.com

> Hi all:
>
[quoted text clipped - 19 lines]
> Thanks,
> Stephen

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.