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
Explain the difference between webfarm and webgardens in .net?
Difference between Response.redirect vs server.transfer?
What are the namespace classes used in asp.net mvc? : asp.net mvc
Explain different types of Caching techniques in ASP.NET?
What does asax stand for?
How do u deploy your asp.net application?
What are the disadvantages of view state?
Which method do you use to kill explicitly a users session?
Explain the difference between globalization and localization techniques
What is the difference between viewstate and hidden field in asp.net?
Why asp.net mvc is better than asp.net? : Asp.Net MVC
How do you remove duplicates without using remove duplicate stage?
Do you support digital rights management to protect my videos?
Explain repository pattern in asp.net mvc? : asp.net mvc
What is a response cookie?