无法将类型'System.Collections.Generic.List <>'隐式转换为'System.Threading.Tasks.Task <>>

最大跨度

我有一个例外。

无法将类型隐式转换'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;
        }
谢尔盖·卡里尼琴科(Sergey Kalinichenko)

当您async在方法声明中丢失时,通常会发生此错误

当您async输入签名时,C#编译器会添加“魔术”,以执行从对象到Task<T>返回该对象的转换

但是,根据您的情况async,这是不必要的,因为您返回的任务已经具有以下结果:

return Task.FromResult<IEnumerable<WebFormFieldContent>>(
    WebFormFields
);

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

无法从'System.Threading.Tasks.Task'转换为'System.Collections.Generic.Dictionary <string,string>'

来自分类Dev

无法从'System.Threading.Tasks.Task'转换为'System.Collections.Generic.Dictionary <string,string>'

来自分类Dev

无法将类型'System.Collections.IList'隐式转换为'System.Collections.Generic.List

来自分类Dev

无法将类型'bool'隐式转换为'system.threading.tasks.task bool'

来自分类Dev

SignalR错误无法将类型'System.Threading.Tasks.Task <object>'隐式转换为'string'

来自分类Dev

无法将类型“ void”隐式转换为“ System.Threading.Tasks.Task”

来自分类Dev

无法将类型'System.Threading.Tasks.Task <String>隐式转换为'string'

来自分类Dev

无法将类型'bool'隐式转换为'System.Threading.Tasks.Task'

来自分类Dev

无法将类型'System.Linq.IQueryable'隐式转换为'System.Collections.Generic.List'

来自分类Dev

无法将类型'System.Linq.IQueryable'隐式转换为'System.Collections.Generic.List

来自分类Dev

无法将类型“System.Collections.Generic.List<<匿名类型:>>”隐式转换为“System.Collections.Generic.List”

来自分类Dev

无法将类型'Task <System.Collections.Generic.IEnumerable <IClass >>隐式转换为'System.Collections.Generic.IEnumerable <IClass>

来自分类Dev

无法将类型'System.Collections.Generic.List <AnonymousType#1>'隐式转换为'System.Collections.Generic.List

来自分类Dev

无法将类型System.Collections.Generic.List <>隐式转换为System.Collections.Generic.List <>

来自分类Dev

无法将类型“System.Collections.Generic.List”隐式转换为“System.Collections.Generic.List<Model.Room”

来自分类Dev

无法将类型'System.Collections.Generic.List <>'隐式转换为'System.Collections.Generic.IList <>'

来自分类Dev

无法将类型'System.Collections.Generic.List <>'隐式转换为'System.Collections.Generic.IList <>'

来自分类Dev

错误“无法将类型“System.Collections.Generic.IEnumerable<int>”隐式转换为“System.Collections.Generic.List<int>”

来自分类Dev

无法在SignalR中将类型'System.Threading.Tasks.Task <object>'隐式转换为'string'

来自分类Dev

无法将类型隐式转换为'System.Collections.Generic.List

来自分类Dev

无法将类型'void'隐式转换为'System.Collections.Generic.List <string>'

来自分类Dev

无法将类型System.Collections.Generic.List <IEnumerable>隐式转换为<IEnumerable

来自分类Dev

无法将类型'int'隐式转换为'System.Collections.Generic.List <QuickTest.Stock>'

来自分类Dev

无法将类型“ void”隐式转换为“ System.Collections.Generic.List”以用于返回语句

来自分类Dev

无法将类型'System.Collections.Generic.List'隐式转换为'string'

来自分类Dev

无法将匿名类型隐式转换为 System.Collections.Generic.List

来自分类Dev

无法将类型“System.Collections.Generic.List<Object>”隐式转换为“string”

来自分类Dev

无法将类型“字符串”隐式转换为“System.Collections.Generic.List<int>”

来自分类Dev

无法将类型“ Microsoft.AspNetCore.Mvc.NotFoundResult”隐式转换为“ System.Threading.Tasks.Task”

Related 相关文章

  1. 1

    无法从'System.Threading.Tasks.Task'转换为'System.Collections.Generic.Dictionary <string,string>'

  2. 2

    无法从'System.Threading.Tasks.Task'转换为'System.Collections.Generic.Dictionary <string,string>'

  3. 3

    无法将类型'System.Collections.IList'隐式转换为'System.Collections.Generic.List

  4. 4

    无法将类型'bool'隐式转换为'system.threading.tasks.task bool'

  5. 5

    SignalR错误无法将类型'System.Threading.Tasks.Task <object>'隐式转换为'string'

  6. 6

    无法将类型“ void”隐式转换为“ System.Threading.Tasks.Task”

  7. 7

    无法将类型'System.Threading.Tasks.Task <String>隐式转换为'string'

  8. 8

    无法将类型'bool'隐式转换为'System.Threading.Tasks.Task'

  9. 9

    无法将类型'System.Linq.IQueryable'隐式转换为'System.Collections.Generic.List'

  10. 10

    无法将类型'System.Linq.IQueryable'隐式转换为'System.Collections.Generic.List

  11. 11

    无法将类型“System.Collections.Generic.List<<匿名类型:>>”隐式转换为“System.Collections.Generic.List”

  12. 12

    无法将类型'Task <System.Collections.Generic.IEnumerable <IClass >>隐式转换为'System.Collections.Generic.IEnumerable <IClass>

  13. 13

    无法将类型'System.Collections.Generic.List <AnonymousType#1>'隐式转换为'System.Collections.Generic.List

  14. 14

    无法将类型System.Collections.Generic.List <>隐式转换为System.Collections.Generic.List <>

  15. 15

    无法将类型“System.Collections.Generic.List”隐式转换为“System.Collections.Generic.List<Model.Room”

  16. 16

    无法将类型'System.Collections.Generic.List <>'隐式转换为'System.Collections.Generic.IList <>'

  17. 17

    无法将类型'System.Collections.Generic.List <>'隐式转换为'System.Collections.Generic.IList <>'

  18. 18

    错误“无法将类型“System.Collections.Generic.IEnumerable<int>”隐式转换为“System.Collections.Generic.List<int>”

  19. 19

    无法在SignalR中将类型'System.Threading.Tasks.Task <object>'隐式转换为'string'

  20. 20

    无法将类型隐式转换为'System.Collections.Generic.List

  21. 21

    无法将类型'void'隐式转换为'System.Collections.Generic.List <string>'

  22. 22

    无法将类型System.Collections.Generic.List <IEnumerable>隐式转换为<IEnumerable

  23. 23

    无法将类型'int'隐式转换为'System.Collections.Generic.List <QuickTest.Stock>'

  24. 24

    无法将类型“ void”隐式转换为“ System.Collections.Generic.List”以用于返回语句

  25. 25

    无法将类型'System.Collections.Generic.List'隐式转换为'string'

  26. 26

    无法将匿名类型隐式转换为 System.Collections.Generic.List

  27. 27

    无法将类型“System.Collections.Generic.List<Object>”隐式转换为“string”

  28. 28

    无法将类型“字符串”隐式转换为“System.Collections.Generic.List<int>”

  29. 29

    无法将类型“ Microsoft.AspNetCore.Mvc.NotFoundResult”隐式转换为“ System.Threading.Tasks.Task”

热门标签

归档