Finalize and Dispose are both methods available to a programmer to aid in the Garbage Collection process (which ensures that memory is freed up as soon as possible when an object goes out of scope).
Finalize :
1 .Finalize() is called by the runtime.
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 want to make
sure that these resources are freed when the Garbage collection happens.
Dispose :
1. Dispose() is called by the user and implemented via the IDisposable interface.
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 and you want to allow them to call Dispose() to clean up and managed resources that were consumed during the objects lifetime.
3. Overriding Dispose() provides a way for the user code to free the unmanaged objects in your custom class.
4. There is no performance benefit in implementing the Dispose method on types that use only managed resources (such as arrays)
because they are automatically reclaimed by the garbage collector.
Using:
Using is simply a block of code that provides a syntax that ensures the correct usage of IDisposable objects. For a full description, see this link:
http://msdn.microsoft.com/en-us/library/yh598w02.aspx
Scott M Schluer
---
MCPD: ASP.NET Developer 3.5
