如果您制作一个副本,您如何最好地解释为什么允许使用 foreach 替换您正在循环的集合的元素。例子:
foreach(Item item in Items)
{
item.modify //or remove or add
}
// will not work
foreach(Item item in Items.ToList())
{
item.modify //or remove. or add
}
//will work altough i dont get it because i am now iterating trough the temporary list
//and changing its elements.
//In my understanding its not like im iterating the list(.ToList) and modifying the source items
//(Items). A graphic representation would be welcome, my interest is to understand the
//matter logically