A foreach uses the IEnumerator interface, which has a Current property, and MoveNext and Reset methods. So there's not even the concept of an index in it. (Also, there's no guarantee what order you're enumerating in.) You'll need to either do your own counting, or use a for loop instead if the collection can take an index.