O'Reilly logo

Programming Visual Basic .NET, Second Edition by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Arrays, Indexers, and Collections

Most of the examples in previous chapters have dealt with one object at a time. In many applications, however, you will want to work with a group of objects all at the same time. A collection is a container that holds a group of objects. Collections are used to hold all the strings in a listbox, to hold all the employees in a company, to hold all the controls on a page, and so forth. This chapter will review the principal collection types offered by the .NET Framework.

The simplest collection in VB.NET is the array. This chapter examines the Array type in detail and also includes coverage of some of the more complicated collection types, including ArrayList, Collection, Queue, and Stack.

In addition, this chapter introduces the concept of indexers, a feature of VB.NET that makes it possible to create your own classes that can be treated like arrays.

Every collection type has certain shared characteristics. These are captured by the collection interfaces. The .NET Framework provides standard interfaces for enumerating, comparing, and creating collections. This chapter concludes with a discussion of the .NET collection interfaces and an example of how you can implement the collection interfaces in your own classes to give your objects collection semantics.

Arrays

An array is an indexed collection of objects, all of the same type. In this chapter, you will learn to work with three types of arrays: one-dimensional arrays, multidimensional ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required