static void FuckWithIDisposable() { System.Console.WriteLine("=> fun with IDisposable:"); MySRCWrapper rw = new MySRCWrapper(); if (rw is IDisposable) { rw.Dispose(); } Console.ReadLine(); }
static void FuckWithIDisposable_try_finally() { System.Console.WriteLine("=> fun with dispose:"); MySRCWrapper rw = new MySRCWrapper(); try { // ...; } finally { // no matter error or not // always call Dispose() rw.Dispose(); } }