foreach()

The foreach statement is used to iterate through the collection to get the information that you want, but can not be used to add or remove items from the source collection to avoid unpredictable side effects.
If you need to add or remove items from the source collection, use a for loop.
A foreach loop can also be exited by the goto, return, or throw statements.

有时候直接用查找会很方便的

原文地址:https://www.cnblogs.com/liuhuan01/p/5542578.html