How to loop through a collection that supports IEnumerable?
问题 How to loop through a collection that supports IEnumerable? 回答1: A regular for each will do: foreach (var item in collection) { // do your stuff } 回答2: Along with the already suggested methods of using a foreach loop, I thought I'd also mention that any object that implements IEnumerable also provides an IEnumerator interface via the GetEnumerator method. Although this method is usually not necessary, this can be used for manually iterating over collections, and is particularly useful when