Question: Visual Studio 2008, C# 3.0.

I have a method below which calls an event handler. I would like to pass the two arguments received by the method to the event handler.

I would like to do something like this:

```
wc.DownloadDataCompleted += wc.DownloadedDataCompleted(strtitle, placeid);

```

Is this even possible, if yes, how would I go about doing it ?

Code Snippet:

```
public void downloadphoto(string struri,string strtitle,string placeid)
{
    using (WebClient wc = new WebClient())
    {
        wc.DownloadDataCompleted += wc_DownloadDataCompleted;
        wc.DownloadDataAsync(new Uri(struri));
    }
}

```

Answer: 
You could create a private class and place the handler in there. E.g.

```
    public void downloadphoto(string struri, string strtitle, string placeid)
    {
        using (WebClient wc = new WebClient())
        {
            wcHandler handler = new wcHandler() { Strtitle = strtitle, Placeid = placeid };
            wc.DownloadDataCompleted += handler.wc_DownloadDataCompleted;
            wc.DownloadDataAsync(new Uri(struri));
        }

    }

    private class wcHandler
    {
        public string Strtitle { get; set; }
        public string Placeid { get; set; }

        public void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            // Do Stuff
        }
    }

```

Although, given the elegance of Jon's answer would probably use that!
Jon Skeet already answered this, showing how to use a lamda expression, but I was still unclear about it. I still needed some more examples, and eventually found this simple case using a button: <http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/74d03fe0-0fa5-438d-80e0-cf54fa15af0e> 

```
void A()  
{  
  Popup parameter = new Popup();  
  buttonClose.Click += (sender, e) => { buttonClose_Click(sender, e, parameter); };  
}  

static void buttonClose_Click(object sender, EventArgs e, Popup parameter)     
{     
  MakeSomethingWithPopupParameter(parameter);  
}

```

In my case, I was using a context menu for a TreeView control, which ended up looking like this:

```
private void TreeViewCreateContextMenu(TreeNode node)
{
    ContextMenuStrip contextMenu = new ContextMenuStrip();

    // create the menu items
    ToolStripMenuItem newMenuItem = new ToolStripMenuItem();
    newMenuItem.Text = "New...";

    // add the menu items to the menu
    contextMenu.Items.AddRange(new ToolStripMenuItem[] { newMenuItem });

    // add its event handler using a lambda expression, passing
    //  the additional parameter "myData"
    string myData = "This is the extra parameter.";
    newMenuItem.Click += (sender, e) => { newMenuItem_Click(sender, e, myData); };

    // finally, set the node's context menu
    node.ContextMenuStrip = contextMenu;
}

// the custom event handler, with "extraData":
private void newMenuItem_Click(object sender, EventArgs e, string extraData)
{
    // do something with "extraData"
}

```