// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; namespace U7 { public class Foobar : IDisposable { public void Dispose() { Console.WriteLine("Disposed"); } } public class Program { public static void Main(string[] args) { using(Foobar fb = new Foobar()) { Console.WriteLine("Doing something"); } } } }