By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,783 Members | 1,347 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,783 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

May 19 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Optimus wrote:
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
May 19 '06 #2

P: n/a
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 Nietzsche
May 19 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.