想使用using(...), 如:
using (Getter process = new Getter()) { //... }
就必须给类实现接口IDisposable
public sealed class Getter: IDisposable { #region Dispose private bool disposed; ~Getter() { Dispose(false); } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } private void Dispose(bool disposing) { if (!disposed) { if (disposing) { //这里处理一些需要手动dispose的 //this.conn.Close(); //this.conn.Dispose(); } } disposed = true; } #endregion }