IList<T> does not have "where"
Asked Answered
C

5

10

In a specific project at my work, I have a method that returns IList. But this interface does not contain where, or FindAll filters. However, when I open a new project, IList contains all. What is the difference?

Crews answered 21/7, 2010 at 11:3 Comment(0)
J
39

Did you import System.Linq ?

Jolyn answered 21/7, 2010 at 11:4 Comment(1)
@Crews - I agree with @Will Dean, it's important to accept answers that help you out from SO. It doesn't just give the answerer reputation, it lets future googlers know which answer helped you figure out your problem.Chalaza
S
6

Nope. IEnumerable<T> has "where" as an extension method.

Assuming your project is .Net 3.5 or greater, you need to have using System.Linq;

Stoppage answered 21/7, 2010 at 11:5 Comment(2)
IEnumerable<T> you mean. :) The plain old IEnumerable is not supported by LINQ - you have to do Cast/OfType first.Rainarainah
@Noldorin: Yeah, I actually had <T>, but I forgot to put it in a code block and StackOverflow lost it... probably got rendered as a HTML tag. Thanks :)Stoppage
N
2

You might find this useful: LINQ, Where() vs FindAll()

Nephritic answered 21/7, 2010 at 11:6 Comment(0)
D
1

Check .NET Framework of opened framework, may be its .NET Fx 2.

System.Linq added in 3.5

Derbyshire answered 21/7, 2010 at 11:6 Comment(0)
D
1

Here's a basic discussion of extension methods in general. As mentioned by others, the Where method is an extension method found in the System.Linq namespace so you need to import it in order to have intellisense detect the existence of those methods.

Debouch answered 21/7, 2010 at 12:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.