I know that when I iterate a IEnumerable, I iterate the source collection, so if I modified the source collection in the next iteration of the IEnumerable it has in count the modificaction.
So I am wondering how it affects that when I have a ordered IEnumerable.
For example, if I have this:
List<MyType> myNoOrderedList //add my items
IEnumerable<MyType> myOrderedIEnumerable = myNoOrderedList
.OrderBy(x => x.Property);
foreach(MyType in myOrderedIEnumerable)
{
//Do something
}
Supose that I have 3 elements in the list, in each iteration on IEnumerable, the list is ordered or only the list is ordered once?
What happen if in "Do something" I add or remove an item? The IEnumerable has initial ordered items or has to order again to has account the modification of the list?