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
how to debug web services on consumer side?
Define satellite assemblies.
What is the difference between “Web.config” and “Machine.Config”?
What is view state and how it works in asp net?
I have created a configuration setting in my web.config and have kept it at the root level. How do I prevent it from being overridden by another web.config that appears lower in the hierarchy?
What is loop in asp.net?
What is the difference between web.config and machine.config in ASP.NET?
what are configuration files?
How will create assesblies at run time?
What is application state?
Mention few asp.net validators.
What is the difference between page directive include and action tag include?
What are the file extensions for razor views?
Which protocol is used to call a web service?
How to rename a table using sql queries?