Skip to content

Instantly share code, notes, and snippets.

@fmork
Created December 13, 2017 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmork/4a4ddf687fa8398d19ddb2df96f0b434 to your computer and use it in GitHub Desktop.
Save fmork/4a4ddf687fa8398d19ddb2df96f0b434 to your computer and use it in GitHub Desktop.
Delegate.Combine with Action<string>
class Program
{
private static Action<string> stringAction;
static void Main(string[] args)
{
stringAction = new Action<string>(s => Console.WriteLine(s));
stringAction =(Action<string>) Delegate.Combine(stringAction, new Action<string>(s => Console.WriteLine(s)));
stringAction("Action called once"); // will be printed twice
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment