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.IEnumerable
和 System.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-不能与类型实参一起使用的更多相关文章
- dotnet 非泛型 类型 System.Collections.IEnumerable 不能与类型实参一起使用
如果在开发的时候遇到非泛型 类型"IEnumerable"不能与类型参数一起使用,那么就是变量的命名空间没弄对 在 dotnet 里面有 System.Collections.IE ...
- NHibernate无法将类型“System.Collections.Generic.IList<T>”隐式转换为“System.Collections.Generic.IList<IT>
API有一个需要实现的抽象方法: public IList<IPermission> GetPermissions(); 需要注意的是IList<IPermission>这个泛 ...
- 无法将类型为“System.Windows.Controls.SelectedItemCollection”的对象强制转换为类型“System.Collections.Generic.IList`1
在WPF中DataGrid 选择事件中获取SelectedItems 报错如下 无法将类型为“System.Windows.Controls.SelectedItemCollection”的对象强制转 ...
- 无法将类型“System.Nullable`1”强制转换为类型“System.Object”。LINQ to Entities 仅支持强制转换 EDM 基元或枚举类型。
在一个项目中使用LINQ和EF时出现了题目所示的异常,搜索了很多资料都找不到解决办法,主要是因为EF方面的知识欠缺. 先将情况记录如下,以供以后参考. 查询主要设计两张表,由外键关联: 在进行下面的查 ...
- 无法将类型“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 ...
- 使用泛型 类型“System.Collections.Generic.IEnumerator<T>”需要 1 个类型参数
解决办法:添加 using System.Collections:命名空间
- MVC 无法将类型“System.Collections.Generic.List<AnonymousType#1>”隐式转换为“System.Collections.Generic.IList<Mvc3Modeltest.Models.Movie>”。存在一个显式转换(是否缺少强制转换?))
1.问题: 2.解决方案:强制指定类型. 解决之.
- 无法将类型“System.Collections.Generic.IEnumerable<EmailSystem.Model.TemplateInfo>”隐式转换为“System.Collections.Generic.List<EmailSystem.Model.TemplateInf
List<Model.Template> templateList = templateBLL.RecommendTemplateByOrder(modelEbay); List<M ...
- C# 通过IEnumberable接口和IEnumerator接口实现泛型和非泛型自定义集合类型foreach功能
IEnumerator和IEnumerable的作用 其实IEnumerator和IEnumerable的作用很简单,就是让除数组和集合之外的类型也能支持foreach循环,至于foreach循环,如 ...
随机推荐
- leetcode 1041——困于环中的机器人
描述: 在无限的平面上,机器人最初位于 (0, 0) 处,面朝北方.机器人可以接受下列三条指令之一: "G":直走 1 个单位 "L":左转 90 度 &quo ...
- babel/core 6.x升级到7.x要碰到的一些坑
刚学习react.js没多久,碰到各种坑.就比如这个问题,弄了我3个小时,终于解决了.其实就是一个小问题. 报错信息: Error: Cannot find module '@babel/core' ...
- NIO 源码分析(05) Channel 源码分析
目录 一.Channel 类图 二.begin 和 close 是什么 2.1 AbstractInterruptibleChannel 中的 begin 和 close 2.2 Selector 中 ...
- 0 ‘+new Array(017)’ 输出? js+相当于Number()类型转换
网站搬迁,给你带来的不便敬请谅解! http://www.suanliutudousi.com/2017/10/20/new-array017-%E8%BE%93%E5%87%BA%EF%BC%9F- ...
- leetcode.字符串.242有效的字母异位词-Java
1. 具体题目 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的字母异位词. 注:判断两个字符串包含的字母是否完全一样. 示例 1: 输入: s = "anagram&q ...
- 6.2_springboot2.x分布式整合Dubbo
1.分布式应用 在分布式系统中,国内常用zookeeper+dubbo组合,而Spring Boot推荐使用全栈的Spring,Spring Boot+Spring Cloud. 分布式系统: 特 ...
- C# String类常用操作
1.string.Compare(s1,s2) 比较 按字母顺序后边的大于前边的 s1<s2 retrun -1 ;s1=s2 return 0; s1>s2 return1. Cons ...
- Hive之explode和lateral view
Hive之explode 一. explode, 行转列. 1.1. 用于array类型的数据 table_name 表名 array_col 为数组类型的字段 new_col array_col被e ...
- 笔记:TCP/IP基础知识
TCP/IP是指利用IP进行通信时必须用到的协议群的统称. 互联网层(网络层) IP IP是跨越网络传送数据包,使整个网络都能收到数据的协议.IP地址在发送数据的时候作为主机的标识. ICMP 用来诊 ...
- leetcode- 距离顺序排序矩阵单元格
C++解法: #include <iostream> #include <vector> #include <map> #include <algorithm ...