Also available at

Also available at my website http://tosh.me/ and on Twitter @toshafanasiev

Wednesday, 18 December 2013

I wanted to confirm the ordering of the invocation list of a multicast delegate created by concatenating two delegates so I put this quick test together. The results were reassuringly unsurprising:

using System;

static class prog
{
  static void Main()
  {
    Action a = () => { Console.Write("a"); };
    Action b = () => { Console.Write("b"); };

    // prints 'ab'
    ((Action)Delegate.Combine(a, b))();

    Console.WriteLine();

    // prints 'ba'
    ((Action)Delegate.Combine(b, a))();
  }
}