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> 可以选择添加命名空间还是修改

2019-8-31-dotnet-非泛型-类型-System.Collections.IEnumerable-不能与类型实参一起使用的更多相关文章

  1. dotnet 非泛型 类型 System.Collections.IEnumerable 不能与类型实参一起使用

    如果在开发的时候遇到非泛型 类型"IEnumerable"不能与类型参数一起使用,那么就是变量的命名空间没弄对 在 dotnet 里面有 System.Collections.IE ...

  2. NHibernate无法将类型“System.Collections.Generic.IList<T>”隐式转换为“System.Collections.Generic.IList<IT>

    API有一个需要实现的抽象方法: public IList<IPermission> GetPermissions(); 需要注意的是IList<IPermission>这个泛 ...

  3. 无法将类型为“System.Windows.Controls.SelectedItemCollection”的对象强制转换为类型“System.Collections.Generic.IList`1

    在WPF中DataGrid 选择事件中获取SelectedItems 报错如下 无法将类型为“System.Windows.Controls.SelectedItemCollection”的对象强制转 ...

  4. 无法将类型“System.Nullable`1”强制转换为类型“System.Object”。LINQ to Entities 仅支持强制转换 EDM 基元或枚举类型。

    在一个项目中使用LINQ和EF时出现了题目所示的异常,搜索了很多资料都找不到解决办法,主要是因为EF方面的知识欠缺. 先将情况记录如下,以供以后参考. 查询主要设计两张表,由外键关联: 在进行下面的查 ...

  5. 无法将类型“System.Collections.Generic.List<anonymous type:string ClassID,string ClsssName>”隐式转换为“System.Collections.Generic.List<Ecology.Model.EnergyFlowGraph>”

    无法将类型“System.Collections.Generic.List<anonymous type:string ClassID,string ClsssName>”隐式转换为“Sy ...

  6. 使用泛型 类型“System.Collections.Generic.IEnumerator<T>”需要 1 个类型参数

    解决办法:添加 using System.Collections:命名空间

  7. MVC 无法将类型“System.Collections.Generic.List<AnonymousType#1>”隐式转换为“System.Collections.Generic.IList<Mvc3Modeltest.Models.Movie>”。存在一个显式转换(是否缺少强制转换?))

    1.问题: 2.解决方案:强制指定类型. 解决之.

  8. 无法将类型“System.Collections.Generic.IEnumerable<EmailSystem.Model.TemplateInfo>”隐式转换为“System.Collections.Generic.List<EmailSystem.Model.TemplateInf

    List<Model.Template> templateList = templateBLL.RecommendTemplateByOrder(modelEbay); List<M ...

  9. C# 通过IEnumberable接口和IEnumerator接口实现泛型和非泛型自定义集合类型foreach功能

    IEnumerator和IEnumerable的作用 其实IEnumerator和IEnumerable的作用很简单,就是让除数组和集合之外的类型也能支持foreach循环,至于foreach循环,如 ...

随机推荐

  1. Decision Tree、Random Forest、AdaBoost、GBDT

    原文地址:https://www.jianshu.com/p/d8ceeee66a6f Decision Tree 基本思想在于每次分裂节点时选取一个特征使得划分后得到的数据集尽可能纯. 划分标准 信 ...

  2. 简单介绍Collection框架的结构

    Collection:List列表,Set集 Map:Hashtable,HashMap,TreeMap Collection  是单列集合 List   元素是有序的.可重复 有序的 collect ...

  3. PHP-FPM 远程代码执行漏洞(CVE-2019-11043)复现-含EXP

    搭建容器 安装golang 利用程序 https://github.com/neex/phuip-fpizdam 安装git Cobra包安装 go get -v github.com/spf13/c ...

  4. JasperReports入门,JasperReports是什么?

    Jasper报表 报表开发过程中面临的常见故障归纳在以下几点: 核心变化:为了反映业务发生变化或改进它通常以改变报告的核心逻辑. 结果输出:有各种各样的格式,报表可导出到如:HTML,文本,PDF,M ...

  5. hadoop命令行

    持续更新中................ 1. 设置目录配额 命令:hadoop dfsadmin -setSpaceQuota 样例:hadoop dfsadmin -setSpaceQuota ...

  6. 从模块到python文件的两种用法

    01模块的四种形式 模块 就是从逻辑上组织python代码(变量,函数,类,逻辑:实现一个功能),本质就是.py结尾的python文件(文件名是test.py的话,它的对应模块名就是test) 包 用 ...

  7. Vue之自建管理后台(二)Vue端设计

    我们先设计Vue的文件夹分布. 在此之前,我们先了解下初始化创建的Vue的文件夹 https://www.cnblogs.com/luoxuemei/p/9812151.html (我引用了这哥们写的 ...

  8. linux 定时执行sql

    说明: 放执行脚本的路径是: /home/vagrant/ssh 文件夹结构: /home |_ vagrant |__ ssh |___ move_order_old_data.sh |___ mo ...

  9. shell脚本将命令的结果赋值给变量的2种写法

    Shell 也支持将命令的执行结果赋值给变量,常见的有以下两种方式: variable=`command`variable=$(command) 第一种方式把命令用反引号` `(位于 Esc 键的下方 ...

  10. JAVA C 数据类型对应

    { Java—C和操作系统数据类型的对应表 Java Type C Type Native Representation boolean int 32-bit integer (customizabl ...