How does C# deal with code reuse?
There are many approaches where C# helps us deal with code reuse. The ability to build libraries, as we did in the previous section, is one of them. One of the most important ones is the fact that the language is object-oriented. Besides, it is worth mentioning the facilities that generics brought to the C# language. This section will discuss the last two we mentioned.
Object-oriented analysis
The object-oriented analysis approach gives us the ability to reuse code in different ways, from the facility of inheritance to the changeability of polymorphism. Complete adoption of object-oriented programming will let you implement abstraction and encapsulation too.
It is important to mention that in Chapter 20, Best Practices in Coding C# 10, we discuss how inheritance can cause complexity in your code. Although the example below presents a valid way to reuse code, consider using composition over inheritance in real-life applications.
...