Finalizable Disposable Class

image_pdfimage_print

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!"); } } [/csharp]