using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Implab { public static class Safe { public static void Dispose(ref T obj) where T : class { var disp = obj as IDisposable; if (disp != null) { disp.Dispose(); obj = default(T); } } } }