JANA GANA MANA

Promoting indian languages
search BLOGS
Login
Add your comments
Want to contribute?
Join JANAGANAMANA



Print this page.




Finalize and Dispose

- ASP.NET

algo(8/22/2008)
Finalize() : 
1.Finalize() is called by the runtime GC.
2.Is a destructor, called by Garbage Collector when the object goes out of scope. 
3.Implement it when you have unmanaged resources in your code, and you want to make sure that these resources are freed when the Garbage collection happens.

Dispose() :
1.Dispose() is called by the user
2.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. 
3.Overriding Dispose() provides a way for the user code to free the unmanaged objects in your custom class.
4.Be sure to call base class dispose if requred(if that also has some unmanaged resources) Do you remember writing virtual destructors in C++?







ONETRAVEL.COM