using System; namespace TestDelegate2 { static class Util { public delegate int NextFunction(); public static void printNext(NextFunction next) { Console.WriteLine(next()); } } class DelegateTest { private int counter = 1; public int next() { return counter++; } } class TestDelegate2 { static void Main(string[] args) { DelegateTest d = new DelegateTest(); DelegateTest d2 = new DelegateTest(); Util.printNext(new Util.NextFunction(d.next)); Util.printNext(new Util.NextFunction(d.next)); Util.printNext(new Util.NextFunction(d2.next)); Util.printNext(new Util.NextFunction(d2.next)); Util.printNext(new Util.NextFunction(d.next)); Console.ReadKey(); } } }