I've been trying to figure this one out.
I was under the impression that when a class method contains any resources, once the method has reached the end of the code and returns it's result (or nothing in the case of void), that all of those resources are gobbled up by the garbage collector and released back to the system.
If this is true, why would anyone ever bother disposing of something, managed or unmanaged? If I have a form that displays data in a DataSet or Array or whatever, those resources need to persist and when the form is closed, the form and all the components and resources associated with it should be released as well right?
If I have a connection to a data source, and it is called in a method, once the method is done (even if the programmer forgets to close the connection) the connection, connection string etc...should all be released from memory right?
I don't seem to understand why it would be necessary to bother with disposing of something that should be disposed of automatically.
Besides, how would someone know what kind of resources are unmanaged? Is there a list somewhere?