jjzjj

C# 列表框集合语法

在快速学习C#的同时,我遇到了这个Collection语法问题。我向列表框lstData添加了一些我自己的类型MyItem的对象。现在我需要在这个列表框中搜索并想到使用优雅的LINQ符号,例如:lstData.Items.Where(x=>x.Text==SearchString)但列表框的项目没有.Where(),尽管我确实包含了“usingSystem.Linq;”命名空间。所以我尝试了:foreach(MyItemitemin(MyItem)lstData.Items)但这会产生构建错误:无法将类型“System.Windows.Forms.ListBox.ObjectColle