zoukankan      html  css  js  c++  java
  • C#

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 
     6 /*------------------------------------------------------------------------------------------------------------
     7  * 类_析构函数:
     8  *      1. 主要用于在类销毁之前释放类实例所使用的托管和非
     9  *           托管资源.
    10  *      2. 隐式的调用了object基类的Finalize()方法
    11  *      3. 无参
    12  *      4. 无返回值
    13  *      5. 不能在结构体中定义析构函数, 只能对类使用析构
    14  *      6. 一个类只能有一个析构
    15  *      7. 无法继承或者重载
    16  *      8. 无法显示调用,只能由垃圾回收期自动调用
    17 ------------------------------------------------------------------------------------------------------------*/
    18 namespace 类_析构函数
    19 {
    20     class Person
    21     {
    22         public  Person()
    23         {
    24 
    25         }
    26         ~Person()
    27         {
    28             // 必须添加引用: System.Windows.Forms
    29             System.Windows.Forms.MessageBox.Show("析构函数被调用了!");
    30         }
    31         /*----------------------------------------------------------------------------------------------
    32          * ~Person() 析构函数被隐式的转换成下面的代码
    33          * ----------------------------------------------------------------------------------------------      
    34         protected override void Finalize()
    35         {
    36             try
    37             {
    38                 Console.WriteLine("析构函数被调用了!");
    39             }
    40             finally
    41             {
    42                 base.Finalize();
    43             }
    44         }
    45         ----------------------------------------------------------------------------------------------*/
    46 
    47     }
    48 
    49     class Program
    50     {
    51         static void Main(string[] args)
    52         {
    53             Person p = new Person();
    54             Console.ReadLine();
    55         }
    56     }
    57 
    58 }
  • 相关阅读:
    Redis 常用命令
    docker安装与配置nginx详细过程
    docker安装与配置redis详细过程
    kettle 查询 tinyint 值为 Y,kettle 查询 tinyint 为布尔值
    kettle 乱码问题处理方案
    Vue响应式原理
    ES6学习笔记1
    xlxs转成Unicode编码的json文件
    移动、PC图片拖拽缩放2
    util
  • 原文地址:https://www.cnblogs.com/DuanLaoYe/p/5354474.html
Copyright © 2011-2022 走看看