<p>This is something that I have never fully grasped in .NET as to the correct application of the .dispose() method.</p>

<p>Say I have something like</p>

<pre><code>Public Class someClass()
  sub someMethod
    ' do some stuff tying up resources
  end sub
End Class

public class mainApp 
  dim _class as new SomeClass
  _class.someMethod()
End Class
</code></pre>

<p>In all cases is it good practice to implement a dispose method, and if so what should go in there?</p>

<p>If it is not the case that every class should have dispose method (which my gut feeling says the shouldn't) what classes should? I have always thought anything which may tie up a resource (i.e. connection, datareader etc) should have a .dispose() which would unallocate these resources. </p>

<p>Also how would you enforce a calling into calling the .dispose() method?</p>

The
```
Dispose()
```
method is used for cleaning up any resources early. Although the garbage collector reclaims any unused memory for you, it's up to you to do deal with things like network/database connections and file handles. Normally, you'd want these things freed up as soon as they're no longer needed, so you implement the disposable pattern and take advantage of the
```
Using
```
statment for calling it within a try/finally block behind the scenes.