Summary

In this chapter, you learned about object creation and, in particular, about constructors and their ability to perform useful actions when a new object is created. The chapter also looked at how memory, otherwise occupied by an object that no longer can be reached, is released with garbage collection, and how other scarce resources can be released with the Dispose design pattern.

The following paragraphs review the important points covered in this chapter.

An instance variable can be initialized in three different ways:

  • Automatically by the runtime. In which case, the instance variable is assigned a default value. The default value depends on the type of the instance variable.

  • Using a declaration initialization, which allows the programmer ...

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