<p>The .NET garbage collector will eventually free up memory, but what if you want that memory back immediately? What code do you need to use in a class <code>MyClass</code> to call</p>

<pre><code>MyClass.Dispose()
</code></pre>

<p>and free up all the used space by variables and objects in <code>MyClass</code>?</p>

This article
has a pretty straightforward walkthrough.  However,
having
to call the GC instead of letting it take its natural course is generally a sign of bad design/memory management,
especially
if no limited resources are being consumed (connections, handles, anything else that typically leads to implementing IDisposable).
What's causing you to need to do this?