ListBox.ObjectCollection 类 :http://msdn.microsoft.com/zh-cn/library/system.windows.forms.listbox.objectcollection.aspxpublic class ObjectCollection : IList, ICollection, IEnumerable不是写了ObjectCollection实现了IEnumerable接口的吗?
那为什么不能用Where方法
listBox20.Items.Where(x =>.....)  //为什么不能用?

解决方案 »

  1.   

    你引用linq命名空间了么?where方法是作为扩展方法添加到Enumerable里面的
      

  2.   

    public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate);
    要泛型的 IEnumerable 接口才扩展出 Where 方法
      

  3.   

    支持的(listBox20.Items as IEnumerable).xxx
      

  4.   

    要指出两点,一个是IList IEnumerable是不支持LINQ的。另一个需要加上using System.Collections;
    要想支持LINQ,必须转换成IEnumerable<T>,使用Cast<T>()、OfType<T>()方法。或者自行foreach转换为IEnumerable<T>。