zoukankan      html  css  js  c++  java
  • 一章:概述(Part 1)

    c#是一种区分大小写的语言。

    采用命令行CSC.EXE 编译程序。

    IDisposable模式

    C#中的昂贵资源比如打开文件的句柄,连接数据库等,都需要通过手工调用IDisposable.Dispose()去释放。并且using语句可以帮助用户及时调用Dispose方法。

    等于在try..catch块中finally中调用该方法。

        public class Demo : IDisposable
        {

            private bool disposed = false;
            #region IDisposable Members


            public void Dispose()
            {
                //the value is true means the dispose method is called by user directly.
                Dispose(true);

                //This object will be cleaned up by the Dispose method. Therefore, you should call GC.SupressFinalize to take this object
                //off the finalization queue and prevent finalization code for this object from executing a second time.
                GC.SuppressFinalize(this);
            }

            private void Dispose(bool disposing)
            {
                if (disposed)
                {
                    return;
                }
                if (disposing)
                {
                    //release managed resources.

                }
                //release unmanaged resources

                disposed = true;
            }

            ~Demo()
            {
                Dispose(false);
            }
            #endregion
        }

  • 相关阅读:
    elementui问题汇总
    微信小程序实现微信授权登录
    微信小程序数据存储
    小程序使用第三方服务,需要中转到一个h5页面,返回到指定页面
    小程序开发,通过左上角返回到指定页面
    万恶之源-基本数据类型(list,tuple)
    基础中的基础
    mybatis_plus实现自动填充和逻辑删除
    本地端口占用解决方案
    maven定义版本以来报红解决方案
  • 原文地址:https://www.cnblogs.com/RitaRichard/p/2082942.html
Copyright © 2011-2022 走看看