Mega Code Archive

 
Categories / C# / Class Interface
 

Finalizable Disposable Class

using System; using System.Collections.Generic; using System.Text; class Program {     static void Main(string[] args) {         using (MyResourceWrapper rw = new MyResourceWrapper()) {         }         MyResourceWrapper rw2 = new MyResourceWrapper();         for (int i = 0; i < 10; i++)             rw2.Dispose();     } } public class MyResourceWrapper : IDisposable {     public void Dispose() {         Console.WriteLine("In Dispose() method!");     } }