
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
552
|
Chapter 9: Delegates, Events, and Anonymous Methods
SalesWeasel Chas made a commission of : $3,700.00
SalesWeasel Ray made a commission of : $0.00
SalesWeasel Biff made a commission of : $39.45
Q4 Sales Earnings on Quarterly Sales of $110,000.00:
SalesWeasel Chas made a commission of : $12,275.00
SalesWeasel Ray made a commission of : $2,975.00
SalesWeasel Biff made a commission of : $124.63
Annual Earnings were $232,000.00
Paid Chas $22,875.00 to produce $77,333.33
FIRE Chas!
Paid Ray $4,600.00 to produce $77,333.33
Paid Biff $254.33 to produce $77,333.33
Discussion
One of the best ways we’ve heard of to describe closures in C# is to think of an
object as a set of methods associated with data and to think of a closure as a set of
data associated with a function. If you need to have several different operations on
the same data, an object approach may make more sense. These are two different
angles on the same problem, and the type of problem you are solving will help you
decide which is the right approach. It just depends on your inclination as to which
way to go. There are times when 100 percent pure object-oriented programming can
get tedious and unnecessary, and closures are a nice way to solve some of those prob-
lems. The
SalesWeasel commission example presented here is ...