Ok, this may be a dumb question, but I'm looking for anything that resembles a C++ destructor in C#.
I know that the garbage collector is used to free up resources, etc. However, destructors can be quite useful for much more than deleting memory or freeing up handles, etc.
Many times (in C++) I will use destructors to trigger events when an object goes out of scope. I actually use some objects just for their destructor. I want to have that capability in C#. Is it possible? I don't care how I get there, as long as I can reliably run some chunk of code based on the event of an object going out of scope.
Any help is appreciated!