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
  • 357
  • 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,924
  • 1
  • 32
  • 48
BudBrot
  • 1,211
  • 2
  • 21
  • 42
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
  • 60,641
  • 8
  • 104
  • 133
  • `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