CHAPTER 33

image

System.Array and the Collection Classes

Many useful operations can be performed with arrays and the .NET Framework collection. This chapter details how the operations are performed and which interfaces and functions are required to enable specific functionality.

Sorting and Searching

The .NET Framework collection classes provide some useful support for sorting and searching, with built-in functions to do sorting and binary searching. The Array class provides the same functionality but as static functions rather than member functions.

Sorting an array of integers is as easy as this:

using System;class Test{    public static void Main() ...

Get A Programmer's Guide to C# 5.0, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.