var source = new List<string> { "A1", "A2", "B1", "B2" };
var filtered = source.Where(s => s.StartsWith("A"));
foreach (var s in filtered)
Console.WriteLine(s); // outputs first A1 and then A2
It seems like Enumerable.Where
keeps the original order of elements when used on an ordered IEnumerable (such as a List<T>
or T[]
). Is this always the case? If yes, where is this documented?