How to loop through a collection that supports IEnumerable?

mrblah picture mrblah · Oct 7, 2009 · Viewed 167.2k times · Source

How to loop through a collection that supports IEnumerable?

Answer

Fredrik Mörk picture Fredrik Mörk · Oct 7, 2009

A regular for each will do:

foreach (var item in collection)
{
    // do your stuff   
}