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循环,如 ...
随机推荐
- 网络数据包最大长度 MTU 分片 转发https://blog.csdn.net/singular2611/article/details/52513406
1.数据链路层对数据帧的长度都有一个限制,也就是链路层所能承受的最大数据长度,这个值称为最大传输单元,即MTU.以以太网为例,这个值通常是1500字节. 2.对于IP数据包来讲,也有一个长度,在IP包 ...
- 深入理解JAVA虚拟机原理之垃圾回收器机制(一)
更多Android高级架构进阶视频学习请点击:https://space.bilibili.com/474380680 对于程序计数器.虚拟机栈.本地方法栈这三个部分而言,其生命周期与相关线程有关,随 ...
- 54-Ubuntu-打包压缩-4-bzip2压缩和解压缩介绍
bzip2 tar和bizp2命令结合可以实现文件打包和压缩 tar只负责打包,但不压缩 用bzip2压缩tar打包后的文件,其扩展名一般为xxx.tar.bz2 在tar命令有一个选项-j可以调用b ...
- 初探Javascript魅力(1)
转自:CSDN--http://blog.csdn.net/cherry_vicent/article/details/42120149 1.javascript是什么 根据用户的一些操作,然后来 ...
- $router和$route的区别,路由跳转方式name 、 path 和传参方式params 、query的区别
一.$router和$route的区别 $router : 是路由操作对象,只写对象$route : 路由信息对象,只读对象 例子://$router操作 路由跳转 this.$router.push ...
- 结对编程-Core 第12组 [pb15061359+pb15061351]
一.项目要求 1.输入题目数量,生成操作数为3~5个的四则运算题目 2.输入上限值控制生成的操作数的最大值以及结果的最大值 3.输入支持的操作符类型:加.减.乘.除.乘方.括号 4.输入支持的操作数类 ...
- Spring:DataSource注入到dao
Spring:DataSource注入到dao 使用DOS命令创建数据库(Mysql) CREATE DATABASE book DEFAULT CHARACTER SET utf8; CREATE ...
- Algo: Binary search
二分查找的基本写法: #include <vector> #include <iostream> int binarySearch(std::vector<int> ...
- leetcode-三角形的最大周长
Python解法: class Solution: def largestPerimeter(self, A: List[int]) -> int: A.sort() for i in rang ...
- c++ TCP 获取客户端IP
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<errno.h> #i ...