If the index matters to you, iterate by the index instead of using foreach.
for (int myIndex=0;myIndex < myDataTable.Rows;myIndex++)
{
DataRow myDataRow = myDataTable.Rows[myIndex];
/// ...
}
[quoted text, click to view] "Bradley" <annonymous@ms.com> wrote in message
news:%23POfL9KPGHA.1532@TK2MSFTNGP12.phx.gbl...
Hi,
I understand that a DataTable has a collection of Rows. If it is a
collection, why is there no obvious way to get an index property from any
given row?
Example code:
....
int myIndex;
foreach (DataRow myDataRow in myDataTable.Rows)
{
// I need to get the zero-based index here:
myIndex = myDataRow.index?
....
}
....
I don't know if an iEnumerator (or something like it) is required, or how to
use it because of my lack of experience in this area. Can anyone help?
Thanks! Bradley