Explain when to use Finalize vs Dispose ?
Explain when to use Finalize vs Dispose ?
Here is a concise answer to the interview question "Explain when to use Finalize vs Dispose in C#":
Use the Dispose method when you need to explicitly free unmanaged resources held by an object, such as file handles, database connections, or native resources. Dispose should be called by the consumer of the object when they are done using it. Implementing Dispose allows you to take advantage of the using statement to ensure Dispose is always called.
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.