我有一个例外。
无法将类型隐式转换
'System.Collections.Generic.List<IntegraPay.Domain.SObjects.Industry>'
为'System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<IntegraPay.Domain.SObjects.Industry>>'
以下是我的属性和方法。
private List<WebFormFieldContent> WebFormFields { get; set; } =
new List<WebFormFieldContent>();
Task<IEnumerable<WebFormFieldContent>> IRegistrationRepository.GetWebFormFields()
{
return WebFormFields;
}
当您async
在方法声明中丢失时,通常会发生此错误。
当您async
输入签名时,C#编译器会添加“魔术”,以执行从对象到Task<T>
返回该对象的转换。
但是,根据您的情况async
,这是不必要的,因为您返回的任务已经具有以下结果:
return Task.FromResult<IEnumerable<WebFormFieldContent>>(
WebFormFields
);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句