Lazy LINQ and Enumerable Objects

Posted by: K. Scott Allen, on 01 Oct 2008 | View original | Bookmarked: 0 time(s)

Someone asked me why LINQ operators return an IEnumerable<T> instead of something more useful, like a List<T>. In other words, in the following code:List<Book> books = new List<Book>(); // ... IEnumerable<Book> filteredBooks = books.Where(book => book.Title.StartsWith("R")); ... we started with a List<Book>, so why isnt the Where operator smart enough to return a new List<Book>, or modify the existing list by removing books that dont match the Where...

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: XLinq | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 998 | Hits: 53

Similar Posts

  • EF4: Lazy Loading on By Default but what about pre Beta 2 Models? more
  • Chat room questions from the EF Tips & Tricks webcast more
  • The "Error creating window handle" exception and the Desktop Heap more
  • LINQ in Action samples in LINQPad more
  • An Extensive Examination of LINQ: Using the Query Syntax more
  • An Extensive Examination of LINQ: An Introduction to LINQ more
  • Creating LINQToTwitter library using LinqExtender more
  • Identity Maps more
  • Athena - A LINQ to flickr API (Release 1.4) more
  • Overloading Entity Framework Methods: More GetObjectStateEntries more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD