choice for collections of objects in a Windows Application development project

Posted on 2006-04-17
Last Modified: 2010-04-16
I am a college student trying to build a small windows application using Visual Studio 2005.

Business Context:

Simulation of a computer science department that contains faculty, students, courses, advisors etc.

My question:

1) Some of the entities will obviously be the ones mentioned above. When I built the class diagram, I felt a good design choice would be that a department class would contain collections of faculty, courses advisors, degree programs etc.

What do you think will be the best collection type to capture these objects or collections of objects such as ArrayList or List ? Can you capture them as Faculty[], advisor[] etc.? If yes, how?

Question by:scarface7
    LVL 6

    Expert Comment

    An ArrayList is good because it's easy to use, plus it can hold any object, as long as you cast it back.

    ArrayList al = new ArrayList();

    //it's easy to add objects to an ArrayList!
    MyObject myObject = new MyObject();

    //it's also easy to cast back to MyObject.
    foreach(MyObject myObj in al)

    //or if you want to use an index, say you added 3 of MyObjects to the ArrayList and
    //you wanted to call the 2nd one in the list

    MyObject myObject = (MyObject)al[1];  //ArrayList is 0 based


    //here we use as to cast the 2nd entry in the ArrayList to a MyObject type and then call MyMethod
    (al[1] as MyObject).MyMethod();
    LVL 1

    Expert Comment

    A hastable is faster in access and in addition it gives you a key value pair where value could be a object. So retrival is based onn they key name and not list of no's as in arraylist.

    I would recommend you to use a hashtable.
    LVL 5

    Accepted Solution

    use the CollectionBase


    using System.Collection;

    public class Faculty


    public class Deptment : CollectionBase
     void AddFaculty(Faculty newFaculty)

    This will give you stronged typed collection. Here's a link that will provide you with more details


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now