In memory collections
Context: LINQ to Objects works on any IEnumerable<T> (arrays, lists, dictionaries, custom collections). All operations are performed in memory.
List<string> fruits = new() { "apple", "banana", "cherry" };var longFruits = fruits.Where(f => f.Length > 5);Performance considerations
Section titled “Performance considerations”- Use streaming operators for large collections
- Materialize with
ToList()when query is reused multiple times
Real-world usage example
Section titled “Real-world usage example”Data processing in console apps: Read a CSV file into a list of objects, then use LINQ to filter, group, and aggregate.
Example: In System.IO you can read lines with File.ReadLines and use LINQ directly.