
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between dispose() and finalize() in C#
In this post, we will understand the difference between the methods ‘dispose’, and ‘finalize’ in C#.
Dispose
This method is defined in the IDisposable interface.
It has to be invoked by the user.
Whenever it is invoked, it helps free the unmanaged resources.
It can be implemented whenever a close() method is present.
It is declared as public method.
It is quick, and instantly disposes an object.
Since it performs instantaneously, it doesn’t affect performance.
Finalize
It is a method that is defined in the java.lang.object class.
It is invoked by the garbage collector.
It helps free the unmanaged resources just before the object is destroyed.
It is implemented to manage the unmanaged resources.
It is declared as private.
It is slower in comparison to the ‘dispose’ method.
Since it is slow, it affects the performance of the websites or applications.
- Related Questions & Answers
- What is the difference between Finalize and Dispose in C#?
- Difference Between Final, Finally and Finalize in Java
- What is the difference between final, finally and finalize() in Java?
- final, finally and finalize in C#
- Difference between C and C++.
- Difference Between C# and C++
- final, finally and finalize in Java
- Difference between Structures in C and C++
- Difference between C# and Visual C#
- Difference between C# and .Net
- Difference between Go and C++.
- Difference between C and Python
- Difference Between C++ and Java
- Difference between strncmp() and strcmp() in C/C++
- Difference between %p and %x in C/C++