Basic LINQ expression for an ItemCollection
It’s because ItemCollection only implements IEnumerable, not IEnumerable<T>. You need to effectively call Cast<T>() which is what happens if you specify the type of the range variable explicitly: var lItem = from object item in lListBox.Items where String.Compare(item.ToString(), “abc”) == 0 select item; In dot notation, this is: var lItem = lListBox.Items .Cast<object>() .Where(item => … Read more