在c#中向EventHandler添加一些参数

时间:2014-09-12 07:48:17

标签: c# windows-phone-8

到目前为止,我正在使用此代码

public void getRankingList(string country,string type)
    {            
        WebClient client = new WebClient();
        client.AllowReadStreamBuffering = true;
        string url = "......";
        client.DownloadStringCompleted += getRankingResult;
        client.DownloadStringAsync(new Uri(url, UriKind.Absolute));
    }
private void getRankingResult(object sender, DownloadStringCompletedEventArgs e)
    {
        .........
    }

所以现在可以在downloadCompleted事件中添加一些para吗?类似的东西:

private void getRankingResult(object sender, DownloadStringCompletedEventArgs e, string Para)
    {
        .........
    }

2 个答案:

答案 0 :(得分:4)

public void getRankingList(string country,string type)
    {            
        WebClient client = new WebClient();
        client.AllowReadStreamBuffering = true;
        string url = "......";
        client.DownloadStringCompleted += (sender, args) => 
        getRankingResult(sender, args, "para");
        client.DownloadStringAsync(new Uri(url, UriKind.Absolute));
    }

private void getRankingResult(object sender, DownloadStringCompletedEventArgs e, string Para)
{
    // .....
}

答案 1 :(得分:1)

如果DownloadStringCompletedEventArgs不是密封类,那么您可以创建一个新类并从中继承并向其添加额外的string Para字段。