Tuesday 5 February 2019

c# - Destructor vs IDisposable?

I've read about disposing objects/IDisposable interface and destructors in C#, but to me they seem to do the same thing?



What is the difference between the two? Why would I use one over the other? In fact, in this example (link below) this code uses both the IDisposable interface and a destructor:



http://msdn.microsoft.com/en-us/library/system.idisposable.aspx



The comment says the destructor is if the finalization code is not used, but how do I decide when to use one over the other?

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...