Question: Objects that derive from HashAlgorithm such as MD5CryptoServiceProvider have a Dispose() method, but it's private. Instead it has a Clear() method which "Releases all resources" used by it.

WTF?

Is this how to correctly dispose of a HashAlgorithm then?

```
var hasher = new MD5CryptoServiceProvider();

byte[] hashCode = hasher.ComputeHash(data);

hasher.Clear();

```

Someone wanna explain this one to me? :)

Answer: 
While the `Dipose()` method is private, if you cast it to `IDisposable` you can gain access to it. As others have said, though, `Clear()` will call it for you.

A better approach, however, is to enclose the declaration and and assignment of the variable in a using() block:

```
byte[] hashCode;

using(var hasher = new MD5CryptoServiceProvider())
{
    hashCode = hasher.ComputeHash(data);
}

```
You should let the GC handle that for you. That's it's job.

Some resources should be disposed of, like DB connections and file handles, so put those in a `using` block (C#). This isn't one of those cases, though.