© Andrew Troelsen and Philip Japikse 2017

Andrew Troelsen and Philip Japikse, Pro C# 7, https://doi.org/10.1007/978-1-4842-3018-3_13

13. Understanding Object Lifetime

Andrew Troelsen and Philip Japikse2

(1)Minneapolis, Minnesota, USA

(2)West Chester, Ohio, USA

At this point in the book, you have learned a great deal about how to build custom class types using C#. Now you will see how the CLR manages allocated class instances (aka objects) via garbage collection. C# programmers never directly deallocate a managed object from memory (recall there is no delete keyword in the C# language). Rather, .NET objects are allocated to a region of memory termed the managed heap, where they will be automatically destroyed by the garbage collector “sometime in ...

Get Pro C# 7: With .NET and .NET Core 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.