Use of simple delegate
<p>a simple delegate just point a function and later when we call delegate then mapped function is invoke.</p>

<p>i hardly use delegate.so i just want to know why one should use simple delegate. here i am giving a sample code of use delegate.</p>

<pre><code>using System;
using System.Windows.Forms;

delegate void DisplayMessage(string message);

public class TestCustomDelegate
{
   public static void Main()
   {
        DisplayMessage messageTarget;

        if (Environment.GetCommandLineArgs().Length &gt; 1)
            messageTarget = ShowWindowsMessage;
        else
            messageTarget = Console.WriteLine;

        messageTarget("Hello, World!");
   }

   private static void ShowWindowsMessage(string message)
   {
      MessageBox.Show(message);
   }
}
</code></pre>

<p>in the above example a delegate just point a function and when we invoke delegate then a function is called which is mapped. here we can directly call the function then why one should use delegate. please explain with good sample which describe the advantage of delegate. in my above program we can directly call ShowWindowsMessage function and there delegate is not required.</p>

<p>thanks</p>
