Suppose we have:
interface Foo { bool Func(int x); } class Bar: Foo { bool Func(int x) { return (x>0); } } class Baz: Foo { bool Func(int x) { return (x<0); } }
Now we can toss around Bar and Baz as a Foos and call their Func methods.
Delegates simplify this a little bit:
delegate bool Foo(int x); bool Bar(int x) { return (x<0); } bool Baz(int x) { return (x>0); }
Now we can toss around Bar and Baz as Foo delegates.
What is the real benefit of delegates, except for getting shorter code?
There is a slight difference, delegates can access the member variables of classes in which, they are defined. In C# (unlike Java) all inner class are consider to be static. Therefore if you are using an interface to manage a callback, e.g. an ActionListener for a button. The implementing inner class needs to be passed (via the constructor) references to the parts of the containing class that it may need to interact with during the callback. Delegates do not have this restriction therefore reduces the amount of code required to implement the callback.
Shorter, more concise code is also a worthy benefit.