• 2019-8-31-dotnet-非泛型-类型-System.Collections.IEnumerable-不能与类型实参一起使用


    title author date CreateTime categories
    dotnet 非泛型 类型 System.Collections.IEnumerable 不能与类型实参一起使用
    lindexi
    2019-08-31 16:55:59 +0800
    2019-04-12 10:24:26 +0800
    dotnet

    如果在开发的时候遇到非泛型 类型“IEnumerable”不能与类型参数一起使用,那么就是变量的命名空间没弄对

    在 dotnet 里面有 System.Collections.IEnumerableSystem.Collections.Generic.IEnumerable<> 两个不同的类,带泛型的需要在 System.Collections.Generic 命名空间找到

    如果是写了 System.Collections.IEnumerable<Foo> 那么请修改代码里面的命名空间 System.Collections.Generic.IEnumerable<Foo> 就可以通过编译

    如果是使用 IEnumerable<Foo> 提示 不能与类型实参一起使用,那么只需要添加 using 就可以

    using System.Collections.Generic;

    除了 IEnumerable 对于 IEnumerator 也一样,如果遇到非泛型 类型“System.Collections.IEnumerator”不能与类型实参一起使用,那么看代码里面是通过 System.Collections.IEnumerator<Foo> 还是 IEnumerator<Foo> 可以选择添加命名空间还是修改

  • 相关阅读:
    关闭游标
    OCP-1Z0-053-200题-19题-601
    OCP-1Z0-053-200题-17题-99
    OCP-1Z0-053-200题-18题-100
    OCP-1Z0-053-V13.02-99题
    OCP-1Z0-053-200题-16题-98
    OCP-1Z0-053-200题-15题-15
    OCP-1Z0-053-200题-14题-675
    OCP-1Z0-053-200题-13题-97
    OCP-1Z0-053-200题-12题-96
  • 原文地址:https://www.cnblogs.com/lindexi/p/12085673.html
Copyright © 2020-2023  润新知