Be Cautious with Large Collections

For very large collections or performance-critical sections, consider using traditional loops:


// For large collections, this might be faster:
var count = 0;
foreach (var item in largeCollection)
{
    if (item.SomeProperty > 100)
    {
        count++;
    }
}

// Instead of:
var count = largeCollection.Count(item => item.SomeProperty > 100);