Putting It Together: An Extensible Calculator

To recap everything learned about delegates so far, create a calculator that can be extended by plugging in new operators. Although we don’t focus on the UI aspect, take a look at Figure 17.13 to see what I have in mind.

Figure 17.13. An extensible calculator.


Besides typical arithmetic operations like add, subtract, multiply, divide, and modulo, four additional programmable function keys are provided. The way the programming is done is something you can dream about, but what’s more interesting is how to create a generic calculator engine in which those custom operations can be plugged.

Let’s try ...

Get C# 4.0 Unleashed now with O’Reilly online learning.

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