IDisposable最佳实现模式
/// <summary> /// 实现了IDisposable接口的类。 /// </summary> public class ConnectionManager : IDisposable { #region IDisposable模式 /// <summary> /// 析构函数。 /// </summary> ~ConnectionManager() { Dispose(false); } /// <summary> /// 真正的释放资源函数。 /// </summary> /// <param name="disposing"></param> protected virtual void Dispose(bool disposing) { if (disposing) { // Clean up all managed resources that is finalizable // ... } // Clean up all native resources // ... } /// <summary> /// 提供使用者一个显式释放资源的方法。 /// </summary> public void Dispose() { Dispose(true); // Tell the GC not to execute the deconstructor any more GC.SuppressFinalize(this); } }
—— Kevin Yang
你可能对下面的文章感兴趣
本博客遵循CC协议2.5,即署名-非商业性使用-相同方式共享
写作很辛苦,转载请注明作者以及原文链接~
如果你喜欢我的文章,你可以订阅我的博客:-D点击订阅我的文章










最新评论
方便提供你自己的博客地址吗?你的博客是刚刚创建的吗?还是已经 创建一段时间了?
你好,按照上面的步骤完成后,搜索时空白,google.sea rch.CustomSearchControl里的id换成你 的博客的id,可以搜到,但我自己咋igoogle申请的...
你好,按照上面的步骤完成后,搜索时空白,google.sea rch.CustomSearchControl里的id...
虽然不是很懂,但还是得说声楼主辛苦了!
谢楼主分享~