IDisposable
自己备用
public static class PHDApi : IDisposable { private PHDAccess _phd = null; // Track whether Dispose has been called. private bool disposed = false; ~PHDApi() { Dispose(false); } public PHDAccess phd { get { if (_phd == null) _phd = new PHDAccess(); return _phd; } set { _phd = value; } } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing && _phd != null) { _phd.Dispose(); _phd = null; } disposed = true; } } }
如果觉得文章对您有帮助,请不吝点个赞,表示一下支持!谢谢!