C# 为什么可以';t我使用以下IEnumerable<;字符串>;?
我得到以下错误:C# 为什么可以';t我使用以下IEnumerable<;字符串>;?,c#,.net,idisposable,C#,.net,Idisposable,我得到以下错误: Error 25 The type or namespace name 'IEnumerable' could not be found (are you missing a using directive or an assembly reference?) C:\Development\Leverage\Leverage\Reports\SurveyLevel.aspx.cs 39 17 Leverage 因为这条线: private IEnume
Error 25 The type or namespace name 'IEnumerable' could not be found (are you missing a using directive or an assembly reference?) C:\Development\Leverage\Leverage\Reports\SurveyLevel.aspx.cs 39 17 Leverage
因为这条线:
private IEnumerable<string> GetDateParameters()
在顶部,但这并不能修复它。您缺少一个
使用System.Collections.Generic代码文件顶部的代码>语句
无法直接找到泛型IEnumerable
类型
您可以声明全名:
private System.Collections.Generic.IEnumerable<string> GetDateParameters()
private System.Collections.Generic.IEnumerable GetDateParameters()
IEnumerable
在系统中。集合
IEnumerable
位于System.Collections.Generic
您只需在代码顶部添加名称空间
属于mscorlib.dll程序集中的此命名空间
你可以像这样使用它
private System.Collections.Generic.IEnumerable<string> GetDateParameters()
private System.Collections.Generic.IEnumerable GetDateParameters()
正如其他人所说,您缺少使用System.Collections.Generic的代码>
但这给了你一条鱼;我们应该教你自己抓鱼
自行解决此问题的方法是:
在您喜爱的搜索引擎中输入类型名称,然后查看返回的内容:
IEnumerable(T)接口(System.Collections.Generic)
公开枚举数,该枚举数支持对指定类型的集合进行简单迭代
看到我用粗体突出显示的那部分了吗?这就是您缺少的名称空间
如果你仍然得到错误,那么你很可能错过了一个参考;通过点击链接并阅读文档页面,您可以找出未能引用的DLL;它将告诉您要引用哪个DLL。以上答案很好。在我的情况下,即使遵循上述答案,它也没有解决问题。然而,红色的波浪不断地出现
问题是项目的框架。它默认设置为.NET Framework 4.0.3,更改为.NET Framework 4.0.0也会有所帮助
在更改后保存项目属性,然后进行生成,所有这些都会正常工作
希望这能有所帮助。但他使用的是IEnumerable
,而不是,它在System.Collections.Generic
中。你有使用System.Collections代码>已声明命名空间?或者如果使用visual studio,只需右键单击类型名称->解析->选择使用
添加一个,或者在命名空间前面添加前缀。我现在很高兴。我现在知道如何找到信息了。非常感谢你!“给一个人一条鱼,你可以喂他一天。但是教他如何使用互联网,他几个星期都不会打扰你。”
private System.Collections.Generic.IEnumerable<string> GetDateParameters()