What is the Difference B/W Finalize() and Dispose() in .Net?
Answer Posted / sreeram pavan
Both are ways to destroy the object. By object i mean when
you have some unmanaged resources used in your class, you
have to make sure that you write the logic to destroy them
in the finalize() method. But this is the implicit way of
destroying the unmanaged resources, as finalize is called by
garbage collector when it find thats there is no reference
to this object from the stack.
There is an explicit way to destroy the unmanaged resources.
That is by implementing IDisposable interface. By
implementing this interface, ie you have to write the code
to destroy the resource in Dispose() method, you can call
the object to destroy itself when ever required in your code.
| Is This Answer Correct ? | 51 Yes | 5 No |
Post New Answer View All Answers
What is difference between asp state management and asp.net state management? How can we pass info between 2 asp.net pages?
Explain about consistent programming model in the .NET framework?
What is the difference between user control an custom control?
What is aspect-oriented programming?
What are session state modes? List some of the important session state modes of asp.net.
What is difference between session and viewstate?
What are the different kinds of assemblies?
If I have more than one version of one assemblies, then how will I use old version (how/where to specify version number?) In my application?
Is react a template engine?
What language is asp.net written in?
How to send a DataReader as a parameter to a remote client ?
Explain the difference between singleton and single call?
How many types of state management are there in asp net?
What are demand-paging and pre-paging?
What is asp.net response object?