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循环,如 ...
随机推荐
- python TypeError: ‘encoding’ is an invalid keyword argument for this function
shell调用python脚本出现了这个问题,查询原因得知,python脚本是python3.6写的,我们服务器上默认的python是python2.7.3,所以会出现编码问题. 解决思路: 1.安装 ...
- JAVA 字符串索引
String类的substring()方法 截取字符串,在java语言中的用法 1. public String substring(int beginIndex) 返回一个新字符串,它是此字符 ...
- Module not found: Error: Can't resolve "xxx" in "xxx"
报错信息 ERROR in multi ./src/index.js ./dist/bundle.js Module not found: Error: Can't resolve './dist/b ...
- VIM查找空格
匹配1到多个空格 /\s\+ 或者开启very magic模式 /\v\s+
- git常用操作笔记
这是我看了廖雪峰的git教程,写的笔记,仅作为一个学习的记录 一.大多数我们面临的是已经有一个进行中的项目了,我们只需克隆下来就可以了 1.安装git,安装完后,可输入git,回车,查看是否已安装 2 ...
- Python 内置函数&filter()&map()&reduce()&sorted()
常用内置函数 Python 2.x 返回列表,Python 3.x 返回迭代器 在进行筛选或映射时,输出的结果是一个数组,需要list帮助. 如:print(list(map(lambda x:x+1 ...
- URL&HTTP协议&GET请求&POST请求
1.什么是URL URL的全称是Uniform Resource Locator(统一资源定位符) 通过1个URL,能找到互联网上唯一的1个资源 URL就是资源的地址.位置,互联网上的每个资源都有一个 ...
- spring boot jpa 多表关联 @OneToOne @OneToMany @ManyToOne@ManyToMany
1.一对一关联 @OneToOne import lombok.Data; import javax.persistence.*; /** * @Author: GWL * @Description: ...
- 访问nginx时验证密码
只允许1.2.3.4这个IP访问我们的站点,拒绝所有其他IP的访问. server { listen 80; server_name www.example.com; satisfy any; all ...
- pandas的read_csv踩到的坑
read_csv要注意,如果没有设置index_col时,读出来的会在索引上方加上Unnamed:0.可以通过设置index_col来解决这个问题. import pandas as pd impor ...