custom destructor and standard Dispose, but the second class doesn’t need either. The difference is that the first class allocates
resources in the constructor and doesn’t clean them up immediately. In contrast, the second class allocates resources in a member function and carefully frees them before exiting (using a finally block), so the second
class author doesn’t need to bother writing Dispose and a destructor. Read more »
VN:F [1.7.2_963]
Rating: 5.0/5 (1 vote cast)
Introduction
This article is about understanding the working concept of destructor in C#. I know you all may be thinking why a dedicated article on simple destructor phenomenon. As you read this article you will understand how different is C# destructor are when compared to C++ destructors.
In simple terms a destructor is a member that implements the actions required to destruct an instance of a class. The destructors enable the runtime system, to recover the heap space, to terminate file I/O that is associated with the removed class instance, or to perform both operations. For better understanding purpose I will compare C++ destructors with C# destructors. Read more »
VN:F [1.7.2_963]
Rating: 3.0/5 (1 vote cast)