我试图帮助其他人并写下这个查询:
var foundTab = (from tab in tabControl1.TabPages
where tab.Name == "tabName"
select tab).First();
他们报告说他们收到了这个错误:
Could not find an implementation of the query pattern for source type System.Windows.Forms.TabControl.TabPageCollection'. 'Where' not found. Consider explicitly specifying the type of the range variable 'tab'.
我检查了 MSDN,TabPageCollection
实现了 IList
、ICollection
、IEnumerable
。那么,这是怎么回事?该错误是什么意思,还有其他方法可以查询选项卡控件的 TabPages
属性吗?
最佳答案
试试这个:
var tab = (from System.Windows.Forms.TabPage tab in tabControl1.TabPages
where tab.Name == "tabName"
select tab).First();
此代码指定范围变量的类型。
关于c# - 为什么这个 LINQ 查询不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1523457/