This chapter discussed reference types, object-oriented features of C#, and exception handling.
You can build your own custom reference type by creating a class. Classes have constructors for initializing the state of the type. They also have destructors for releasing unmanaged resources when the type is garbage collected. Because using destructors for releasing unmanaged resources is inadequate, you should use the dispose pattern, which will be discussed in the next chapter in the section on interfaces.
C# is an object-oriented programming language and supports inheritance, encapsulation, and polymorphism. In C#, base type members must be declared as virtual and be explicitly overridden in derived types to implement polymorphism, which differs from languages like C++ and Java where all methods are implicitly virtual. The new modifier enables a derived type to explicitly state its intention to hide base type members.
Applications should implement exception-handling mechanisms to ensure that they are robust enough to survive unexpected errors. Exceptions are implemented by wrapping suspect code in a try/catch block. A finally block should be used to force cleanup to happen regardless of whether there was an error or not.