Skip to Content
Programming Visual Basic .NET, Second Edition
book

Programming Visual Basic .NET, Second Edition

by Jesse Liberty
April 2003
Intermediate to advanced
560 pages
14h 4m
English
O'Reilly Media, Inc.
Content preview from Programming Visual Basic .NET, Second Edition

The Collection Interfaces: IEnumerable

While the Array is the simplest type of collection, there are times when you need additional functionality. The .NET Framework provides a number of already built and tested collection classes, including the ArrayList, Collection, Queue, and Stack. These standard classes are covered later in this chapter.

Chapter 8 introduced the concept of interfaces, which create a contract that a class can fulfill. Implementing an interface allows clients of the class to know exactly what to expect from the class. The .NET Framework provides a number of standard interfaces for enumerating, comparing, and creating collections.

These collection interfaces make it possible for you to write your own custom collection classes. By implementing the collection interfaces, your custom classes can provide the same semantics as the collection classes available through the .NET Framework. Table 9-2 lists the key collection interfaces and their uses.

Table 9-2.  The collection interfaces

Interface

Purpose

IEnumerable

Designates a class that can be enumerated

IEnumerator

Designates a class that iterates over a collection; supports the For Each loop

ICollection

Implemented by all collections

IComparer

Compares two objects; used for sorting

IList

Used by collections that can be indexed

IDictionary

For key/value-based collections

IDictionaryEnumerator

Allows enumeration with For Each of a collection that supports IDictionary

This section will ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Visual Basic .NET

Programming Visual Basic .NET

Dave Grundgeiger
VB.NET Language in a Nutshell, Second Edition

VB.NET Language in a Nutshell, Second Edition

Steven Roman PhD, Ron Petrusha, Paul Lomax

Publisher Resources

ISBN: 0596004389Supplemental ContentCatalog PageErrata