Chapter 12. Constructors and Finalizers

After having covered the code and data aspects of types by exploring methods, fields, properties and indexers, we’re now ready to discuss where both aspects clearly meet. This includes logic to initialize a type (by means of a static constructor) and its instances (by means of an instance constructor). Furthermore, sometimes it’s needed to perform certain clean-up actions upon destruction of an object instance. As you’ll see, this use of so-called finalizers can be reduced to a minimum due to the presence of garbage collection. In some cases though, use of finalizers is required to ensure proper ...

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