From the course: Visual Basic Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Iterate over list

Iterate over list - Visual Basic Tutorial

From the course: Visual Basic Essential Training

Start my 1-month free trial

Iterate over list

- [Instructor] It's time to look at the for each looping keywords. Essential for each let's us loop through a collection of items and work with each item in the list. To make this work .net has two important interfaces. I'll show examples in this class diagram, ClassDiagram1.cd. Which I've added to the Visual Studio project. It allows us to visualize .net types and is available as an extra component in the Visual Studio installer. This shows the two important interfaces IEnumerable and IEnumerable(Of T). If a type implements either one of these interfaces you can for each over the items in that collection. I'm showing three example items. I've got list of T, which implements both the interfaces. I've got the array class, which implements IEnumerable and here's a type that I'll use later in this chapter called SortedSet. And it implements both IEnumerable(Of T) and Ienumerable. Let's switch over to the code. My first…

Contents