0

I am trying to implement a iDisposable class and I saw a code like that

public class Foo: IDisposable 
{

    public void Dispose()
    {
        // Does Something.
    }

    ~Foo()
    {

    }
}

what does ~Foo()?

Raoni Zacaron
  • 367
  • 5
  • 15

2 Answers2

0

Take a look at the Msdn, it has a really good and simple example what a destructor does http://msdn.microsoft.com/en-us/library/66x5fx1b.aspx

MattC
  • 3,984
  • 1
  • 33
  • 49
BudBrot
  • 1,341
  • 2
  • 24
  • 44
0

It is a Finalizer and its purpose is to clean up any unmanaged resources the class holds. There is a whole lot of information to learn about what Finalizers are for and how they work.

Simon Whitehead
  • 63,300
  • 9
  • 114
  • 138
  • `IDisposable` is probably a better fit for such things and the finalizer would just call `Dispose()` in case it wasn't called previously. – Joey Jan 16 '14 at 12:24
  • My point was that there is a whole theory around how the Garbage Collector handles types that implement a Finalizer. – Simon Whitehead Jan 16 '14 at 12:30