Q:

What is the difference between dispose and finalize methods in c#?

0

What is the difference between dispose and finalize methods in c#?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Dispose: This method uses interface – “IDisposable” interface & it will free up both managed and unmanaged codes like – database connection, files etc. It belongs to the IDisposable interface. Implement this method when you are writing a custom class that will be used by other users.

Finalize: This method is called internally unlike Dispose method which is called explicitly. It is called by the garbage collector and can’t be called from the code. Finalize belongs to System.Object class. Implement this method when you have unmanaged resources in your code, and make sure that these resources are freed when the Garbage collection happens.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Top 100 C# interview questions and answers 2022

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
What is the difference between string and StringBu... >>
<< What is the difference between “constant” and ...