Lambda expressions in C#?

Posted by user30457 on Super User See other posts from Super User or by user30457
Published on 2010-03-12T20:02:41Z Indexed on 2010/03/12 20:08 UTC
Read the original article Hit count: 535

Filed under:

Hey I'm rather new to these could someone explain the significance or prehaps give a link to some useful information on lambda expressions? I encounter the following code in a test and I am wondering why someone would do this:

foo.MyEvent += (o, e) => { fCount++; Console.WriteLine(fCount); }; foo.MyEvent -= (o, e) => { fCount++; Console.WriteLine(fCount); };

My instinct tells me it is something simple and not a mistake, but I don't know enough about these expressions to understand why this is being done.

Regards,

© Super User or respective owner

lambda expressions in C#?

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-03-12T20:11:39Z Indexed on 2010/03/12 20:17 UTC
Read the original article Hit count: 535

Filed under:

Hey I'm rather new to these could someone explain the significance (of the following code) or prehaps give a link to some useful information on lambda expressions? I encounter the following code in a test and I am wondering why someone would do this:

foo.MyEvent += (o, e) => { fCount++; Console.WriteLine(fCount); };

foo.MyEvent -= (o, e) => { fCount++; Console.WriteLine(fCount); };

My instinct tells me it is something simple and not a mistake, but I don't know enough about these expressions to understand why this is being done.

Regards,

© Stack Overflow or respective owner

Related posts about c#