What is the difference between Finalize() and Dispose()?
Difference between Finalize() and Dispose()
Hi
What is the difference between Finalize() and Dispose()?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Farooque AliRank #7,940 · 231 reputationPosted Aug 2, 2012, 10:52 PM EDT
Dispose(): of IDisposable interface is called by the programmer to explicitly release resources when they are no longer being used. Dispose () can be called even if other references to the object are alive
Jignesh TrivediRank #16 · 50.3K reputationPosted Aug 2, 2012, 11:57 PM EDT
Finalize :
Finalize() is called by the runtime
it is a destructor and called by Garbage Collector when the object goes out of scope.
Implement it if we have unmanaged resources in your code, and want to make sure that these resources are freed when the Garbage collection happens.
Dispose :
Dispose() is called by the user
Same purpose as finalize, to free unmanaged resources. However, implement this when you are writing a custom class, that will be used by other users.
Overriding Dispose() provides a way for the user code to free the unmanaged objects in your custom class.
please refer
http://forums.asp.net/t/466400.aspx/1
hope this will help.