Using Lambda Statements for Event Handlers

Posted by lush on Stack Overflow See other posts from Stack Overflow or by lush
Published on 2010-03-17T18:56:40Z Indexed on 2010/03/17 19:01 UTC
Read the original article Hit count: 170

Filed under:
|
|
|

I currently have a page which is declared as follows:

public partial class MyPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //snip
        MyButton.Click +=
            (o, i) =>
            {
                //snip
            }
    }
}

I've only recently moved to .NET 3.5 from 1.1, so I'm used to writing event handlers outside of the Page_Load. My question is; are there any performance drawbacks or pitfalls I should watch out for when using the lambda method for this? I prefer it, as it's certainly more concise, but I do not want to sacrifice performance to use it. Thanks.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET