What does the syntax"~[Class name]" mean?

  • Thread starter Thread starter Optimus
  • Start date Start date
O

Optimus

Hi everyone,

I got a question about a syntax in c# which I'm not
familiar with.

And then I've got some sample source code as shown below.

public class Window: System.Windows.Forms.Form
{
public Window(){
// some code here
}

~Window()
{
windowFont.Dispose();
}
}

Is that the symbol ~ which prior to the class name identify
the beginning of dispose method?

Anyone've got an idea?


Regards,
Sarun Sermsuwan
 
Optimus said:
Hi everyone,

I got a question about a syntax in c# which I'm not
familiar with.

And then I've got some sample source code as shown below.

public class Window: System.Windows.Forms.Form
{
public Window(){
// some code here
}

~Window()
{
windowFont.Dispose();
}
}

Is that the symbol ~ which prior to the class name identify
the beginning of dispose method?

Anyone've got an idea?


Regards,
Sarun Sermsuwan
It indicates the finalizer(destructor) method.

JB
 
Hello Optimus,

It's destructor, that calls Finilize
See description there http://msdn2.microsoft.com/en-us/library/66x5fx1b.aspx

O> And then I've got some sample source code as shown below.
O>
O> public class Window: System.Windows.Forms.Form
O> {
O> public Window(){
O> // some code here
O> }
O> ~Window()
O> {
O> windowFont.Dispose();
O> }
O> }
O> Is that the symbol ~ which prior to the class name identify the
O> beginning of dispose method?

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top