Chapter 8. Arrays, Collections, and Generics
WHAT YOU WILL LEARN IN THIS CHAPTER
Working with arrays
Iteration (looping)
Working with collections
Generics
Nullable types
Generic collections
Generic methods
Covariance and contravariance
In the beginning there were variables, and they were good. The idea that you map a location in memory to a value was a key to tracking a value. However, most of us want to work on data as a set. Taking the concept of a variable holding a value, we moved to the concept of a variable that could reference an array of values. Arrays improved what developers could build but they weren't the end of the line.
Over time certain patterns developed in how arrays were used. Instead of just collecting a set of values, we looked to use arrays to temporarily store values that were awaiting processing, or to provide sorted collections. Each of these patterns started as a best practice for how to build and manipulate array data or to build custom structures that replicate arrays.
The computing world was very familiar with these concepts — for example, using a linked list to enable more flexibility regarding how data is sorted and retrieved. Patterns such as the stack (first in, last out) or queue (first in, first out) were in fact created as part of the original base Class Libraries. Referred to as collections, they provide a more robust and feature-rich way to manage sets of data than arrays can provide. These were common patterns prior to the introduction of .NET, and .NET ...
Get Professional Visual Basic® 2010 and .NET 4 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.