Instantiating Action<(Of <(T>)>) delegate rather than defining a new delegate : Action « Development « C# / CSharp Tutorial






using System;
using System.Windows.Forms;

public class TestAction1
{
   public static void Main()
   {
      Action<string> messageTarget; 

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

      messageTarget("Hello, World!");   
   }      

   private static void ShowWindowsMessage(string message)
   {
      MessageBox.Show(message);      
   }
}








14.41.Action
14.41.1.Instantiating Action<(Of <(T>)>) delegate rather than defining a new delegate
14.41.2.Use Action<(Of <(T>)>) delegate with anonymous methods
14.41.3.Assign a lambda expression to an Action<(Of <(T>)>) delegate instance