Bram <b.*****@gmail.comwrote:
Events are multicast and delegates are single-cast.
No, that's not true at all.
An event is fundamentally just a pair of methods - add and subscribe.
They've got to use delegates to do their job properly. Delegates are
inherently multicast. (At one stage MS was going to differentiate
between single-cast and multicast, hence Delegate and
MulticastDelegate, but they decided against it in the end.)
Here's a short but complete example demonstrating this - no events are
used anywhere, but it's clearly multicast behaviour.
using System;
class Test
{
static void Main()
{
Action<stringx = FirstMethod;
x += SecondMethod;
x ("Test");
}
static void FirstMethod(string s)
{
Console.WriteLine ("First: {0}", s);
}
static void SecondMethod(string s)
{
Console.WriteLine ("Second: {0}", s);
}
}
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too