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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Aug 3, 2012, 3:57 AM
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.
Farooque AliPosted Aug 3, 2012, 2:52 AM
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