Thread: Delegates help
View Single Post
Old 07-25-2008   #4 (permalink)
Jon Skeet [C# MVP]


 
 

Re: Delegates help

Miro <miro@xxxxxx> wrote:
Quote:

> I might still be missing something but I see how the delegate points to the
> function/method :
>
> But I still seem to be missing why I wouldnt call the sub "DisplayMessage"
> directly? Why delegate it?
In this case, you wouldn't. The point is to be able to effectively pass
some logic to other pieces of code.

See http://csharpindepth.com/Articles/Ch.../Closures.aspx for an
article which concentrates on closures, but should also give you a
flavour of why delegates are a good thing.

--
Jon Skeet - <skeet@xxxxxx>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
My System SpecsSystem Spec