What is the Difference B/W Finalize() and Dispose() in .Net?
Answer Posted / purushottam kumar, mcad, mcsd
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
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.
| Is This Answer Correct ? | 9 Yes | 0 No |
Post New Answer View All Answers
Write a code snippet to implement the indentation in json in web api.
What is asp.net web application?
Can we have 2 web config files?
Explain the difference between response.redirect vs server.transfer
What is recordset asp?
Explain the path instructions in xaml?
Which platform does Microsoft .NET use for exchanging data between applications?
Explain difference between dataset and datareader?
How to add DateTime Control in normal DataGrid Server Control?
Explain authorization levels in .net ?
What is directive in asp net?
Explain the difference between value type and reference type?
What do you mean by authentication?
What are the parts of an http response?
Define repository pattern in mvc.net? : asp.net mvc