gpt4 book ai didi

c# - 返回类型错误

转载 作者:行者123 更新时间:2023-11-30 18:53:40 25 4
gpt4 key购买 nike

我不明白为什么会出现以下错误:

'System.Collections.Generic.List Notify.MainPage.webClient_OpenReadCompleted(object, System.Net.OpenReadCompletedEventArgs)' has the wrong return type

代码:

webClient.OpenReadCompleted += webClient_OpenReadCompleted;

和:

private List<SightingType> webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
DataContractJsonSerializer ser = null;
var sightingT = new List<SightingType>();
try
{
ser = new DataContractJsonSerializer(typeof(ObservableCollection<SightingType>));
ObservableCollection<SightingType> sightingTypes = ser.ReadObject(e.Result) as ObservableCollection<SightingType>;
foreach (var sightingType in sightingTypes)
{
sightingT.Add(sightingType);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

return sightingT;
}

有谁知道我哪里出错了?

最佳答案

事件处理程序的返回类型应为 void:

private void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{

另一端没有接收返回数据的东西。

关于c# - 返回类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17707000/

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