It depends on the type oPrcs. If it is a Process[], then it will be:
for (int i = 0; i < oPrcs.Length; i++)
{
Process newprcs = oPrcs[i];
...
}
Otherwise, if the type oPrcsimplements IEnumerable<Process>(to which it is not necessary, but, as a rule, it should turn out:
using (IEnumerator<Process> iterator = oPrcs.GetEnumerator())
{
while (iterator.MoveNext())
{
Process newprcs = iterator.Current;
...
}
}
Having said all this, I usually did not convert the loop foreachto loop for...
source
share