Working with Collections - Day 2 - Part 6

Download this episode

Download Video


You will often need to work with groups of instances of classes and this video explains how to use one collection—the List<T>—to keep references to multiple instances of a given class. Bob demonstrates how to add instances of objects to a collection and how to iterate through each instance inside the collection using the “for each” statement, a variation on the “for iteration” statement we learned about on Day 1.

Download the source code in c#

Download the source code in VB.Net



Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image

      So would you say a List is similar to an array? Looks pretty similar, and I like the foreach loop.

      Cheers Bob

    • User profile image

      Arrays do exist in C#, but I like Lists much better. With lists, you don't have to define a maximum size, and are generally much easier to work with. 

    • User profile image

      @Mintydog: Lists allow you to do a bit more complex operations like inserting, removing, ...

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.