I look at msdn class lib, it mentions == and != op for Delegate, but does
not mention operators += and -=
My question is: for -=, is that calling Delegate.Remove() or RemoveAll()?
Thanks,
Ryan
Hint: what does the following code do when you execute it...
Action action1 = () => Console.WriteLine("called"),
action2 = null;
action2 += action1;
action2 += action1;
action2 -= action1;
action2();
?
"Peter Duniho" <no.pet...@no.nwlink.spam.com> wrote in message
news:u3%23ltycX...@TK2MSFTNGP06.phx.gbl...
>?
Just asking about the lambda notation above. I understand that => is
short hand for an anonymous method. Is this correct? If yes, then what
would the long hand version of the above example look like ? (without
the lambda notation)
Thankds,
Rich
*** Sent via Developersdex http://www.developersdex.com ***
Sort of. The => is specifically for writing a lambda expression.
Depending on context, this can either be compiled into an anonymous
method or an actual expression.
So, technically it's not really "short hand" for anything. It simply
"is" a lambda expression. But yes, in a way you can think of it as
short-hand for an anonymous method, because in that context, that's what
it winds up creating.
> If yes, then what
> would the long hand version of the above example look like ? (without
> the lambda notation)
Action action1 = delegate() { Console.WriteLine("called"); };
As you can see, for this specific usage, there's very little difference.
Pete