CHAPTER 10 ■ DELEGATES, ANONYMOUS FUNCTIONS, AND EVENTS266
Anonymous Methods
Many times, you may find yourself creating a delegate for a callback that does something very sim-
ple. Imagine that you’re implementing a simple engine that processes an array of integers. Let’s say
that you design the system flexibly, so that when the processor works on the array of integers, it uses
an algorithm that you supply at the point of invocation. This pattern of usage is called the Strategy
pattern. In this pattern, you can choose to use a different computation strategy by providing a
mechanism to specify the algorithm to use at run time. A delegate is the perfect tool for implement-
ing such a system. Let’s see what an example would look like:
using System;
public ...