A Practical Example

Until now, simple examples have been provided to demonstrate operator overloading and conversion operators. The following code contains a more practical example. Summation notation iterates and totals an expression in a specified range. Figure 9-1 provides three examples of summation notation.

Examples of summation notation

Figure 9-1. Examples of summation notation

Summation is not a predefined type in C#. The following class defines the Summation type. It contains several methods, and the objective is to make the Summation class as similar to a primitive type as possible:

  • The Summation class has three constructors. The two- and three-argument constructors call ...

Get Programming Microsoft® Visual C#® 2008: The Language 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.