zoukankan      html  css  js  c++  java
  • 理解析构函数的执行过程

    Code
    class First
        {
            
    public First()
            {
                System.Console.WriteLine(
    "First class start!");
            }
            
    ~First()
            {
                System.Console.WriteLine(
    "First's destructor is called");
                System.Console.ReadLine();
            }
        }

        
    class Second : First
        {
            
    public Second()
            {
                System.Console.WriteLine(
    "Second class start!");
            }
            
    ~Second()
            {
                System.Console.WriteLine(
    "Second's destructor is called");
            }
        }

        
    class Third : Second
        {
            
    public Third()
            {
                System.Console.WriteLine(
    "Third class start!");
            }
            
    ~Third()
            {
                System.Console.WriteLine(
    "Third's destructor is called");
            }
        }

        
    class TestDestructors
        {
            
    static void Main()
            {
                Third t 
    = new Third();
            }
        }

    First class start!

    Second class start!

    Third class start!

    Third's destructor is called

    Second's destructor is called

    First's destructor is called

    析构函数的执行过程实际是执行了Finalize方法,具体的方法实际是:

    protected overrid Finalize()

    {

      try

        {

          //implemention

        }

      Finally

        {

           base.Finalize();

        }

    }

  • 相关阅读:
    ie浏览器设定主页修改
    诺基亚5800通讯录倒入到dopod的联系人中去的解决办法
    局域网中根据IP地址反查主机的名称(C#)
    U盘维修
    查找xml文件中某接点的值
    如何更改任务栏颜色
    如何给一个div赋值(改变div原来的值)
    explicit的作用
    重建二叉树
    常函数
  • 原文地址:https://www.cnblogs.com/shineqiujuan/p/1500516.html
Copyright © 2011-2022 走看看