gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 14:55:15 24 4
gpt4 key购买 nike

现在我有了这段代码

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 事件添加一些参数吗?像这样的东西:

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

最佳答案

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)
{
// .....
}

关于c# - 在 C# 中向 EventHandler 添加一些参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25803307/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com