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 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.