4
Classes and C# Advanced Features
4.1 INTRODUCTION AND OBJECTIVES
In this chapter we discuss several object-oriented and interface-based language features in C# that allow developers to create flexible and efficient applications. In particular, we discuss a number of techniques that are not seen in some other object-oriented languages, such as the delegate mechanism. The main building blocks are interfaces, abstract classes and abstract methods, delegates and lambda functions. We also combine these techniques to create modular and loosely coupled systems for bond pricing, bond option pricing and for approximating the solution of differential equations using the Finite Difference Method (FDM). We also introduce the Visitor design pattern that allows us to extend the functionality of classes and class hierarchies in a non-intrusive manner. Design patterns are discussed in more detail in Chapter 18.
Many of the language features that we describe here will be applied in more complex applications in later chapters. This chapter serves as a reference and it can be consulted when you wish to recall some C# syntax that you would like to use in your applications. Finally, the examples in this chapter can be used as prototypical models for more complex models.
In short, this chapter shows how modern software design principles are realised in C#. The style is didactic and is meant to explain some advanced concepts.
4.2 INTERFACES
We introduced interfaces in Chapter 3. In particular, we ...
Get C# for Financial Markets 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.