code to play with

class First
{
    ~First()
    {
        System.Diagnostics.Trace.WriteLine("First’s destructor is called.");
    }
}
class Second : First
{
    ~Second()
    {
        System.Diagnostics.Trace.WriteLine("Second’s destructor is called.");
    }
}
class Third : Second
{
    ~Third()
    {
        System.Diagnostics.Trace.WriteLine("Third’s destructor is called.");
    }
}
class TestDestructors
{
    static void Main()
    {
        Third t = new Third();
    }
}
/* Output (to VS Output Window):
    Third’s destructor is called.
    Second’s destructor is called.
    First’s destructor is called.
*/

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s