Foreach错误“foreach语句不能对类型变量”进行轻快删除 [英] Foreach error "foreach statement cannot operetta on variables of type"
本文介绍了Foreach错误“foreach语句不能对类型变量”进行轻快删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HtmlElement texts = webBrowser1.Document.GetElementById("text-conent");
string kq = "";
foreach (var item in texts)
{
kq += item.InnerText + Environment.NewLine;
}
richTextBox1.Text = kq;
程序错误:
foreach声明不能轻松上载system.windows.forms.htmlelement类型的变量,因为system.windows.forms.htmlelement不包含GetEnumenrator的公共定义
Program error:
foreach statement cannot operetta on variables of type "system.windows.forms.htmlelement" because "system.windows.forms.htmlelement" does not contain a public definition for GetEnumenrator
推荐答案
foreach
只能处理项目集合:特别是那些实现IEnumerable(或IEnumerable< T>)接口的项目。
您可能需要使用它所有财产 [ ^ ] - 但这取决于您的其他代码。
foreach
can only work on collections of items: specifically ones that implement the IEnumerable (or IEnumerable<T>) interface.
It's possible you need to use it's All property[^] - but that's down to your other code.
foreach (var item in texts.All)
Div标签:
Div Tags:
<div id="divTop">
<div id="chart" style="width: 500px; float: right;"></div>
<div id="grid" style="margin-removed 505px; height: 700px;"></div>
</div>
这篇关于Foreach错误“foreach语句不能对类型变量”进行轻快删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文