Question about IEnumberable Interface.


I'm learning and I have a question about the IEnumberable <T> Interface, and possibly about LINQ aswell.

I was looking at how to implement a search function and came across the following code:

var movies = from m in db.Movies select m; if (!String.IsNullOrEmpty(searchString)) { movies = movies.Where(s => s.Title.Contains(searchString)); } 

I understand it just fine except for one part.

Where it goes var movies = "LINQ Query.." , the var that it creates is an IEnumerable<MvcMovies.Models.Movie>. So I did a bit of reading on IEnumerable and I learn that IEnumerable has only one method, which is the GetEnumerator() method. How come then that I can do movies.Where to find whatever objects match my search string? Is it because I use it in conjunction with a LINQ Query?

by djputinvodkaparrot via /r/csharp

Leave a Reply