2.12. Manipulate or Evaluate the Contents of an Array

Problem

You need to perform actions on the contents of an array, such as the following:

  • Determining whether an array contains any data

  • Determining whether an array contains any elements that meet a specific condition

  • Determining whether all elements of an array meet a specific condition

  • Reversing the order of the contents

Solution

Use the appropriate methods (such as All, Any, and Reverse) of the System.Linq.Enumerable class to perform the desired action.

How It Works

The .NET Framework 3.5 introduces the NotInheritable class System.Linq.Enumerable, which contains a long list of special Shared methods, some of which are shown in Table 2-6, called extension methods (which are discussed in recipe ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach 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.