Summary

This chapter discussed various methods of overloading in C#, and the difference between overriding and overloading.

The first section discussed overloading of methods. It explained how to vary the number and type of parameters to produce overloaded methods.

The next section covered indexers. It showed a few different ways to define indexers, making a class act like a two-dimensional array. Example indexers were overloaded so the class could be used in an intuitive and flexible manner, depending on requirements.

C# also allows operator overloading. I discussed which operators could and could not be overloaded, as well as the rules that require certain operators to be overloaded in pairs.

Finally, this chapter explained how overload resolution ...

Get C# Unleashed 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.