Chapter 9: Resource Management

In previous chapters, we discussed and worked with value types and reference types and have also seen how they differ. We also briefly talked about how the runtime is managing the allocated memory.

In this chapter, we will get into more details of this topic and look at the language features and best practices for managing memory and resources.

The topics that will be discussed in this chapter are as follows:

  • Garbage collection
  • Finalizers
  • The IDisposable interface
  • The using statement
  • Platform invoke
  • Unsafe code

By the end of this chapter, you will have learned how to implement disposable types and how to dispose of objects when they are no longer needed. You will have also learned how to call native APIs and ...

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