Advanced
C#
Q62 / 100
What is the Dispose pattern and when should you implement a finalizer?
Correct! Well done.
Incorrect.
The correct answer is B) Only add a finalizer if the class directly owns unmanaged resources (handles). Implement the full Dispose(bool disposing) pattern to handle both Dispose() and GC finalization
B
Correct Answer
Only add a finalizer if the class directly owns unmanaged resources (handles). Implement the full Dispose(bool disposing) pattern to handle both Dispose() and GC finalization
Explanation
Finalizers (~MyClass) are a safety net for unmanaged resources. They delay GC and should be suppressed via GC.SuppressFinalize(this) when Dispose() is called.
Progress
62/100