generally, don't like to mix methods for rolling through a
collection, so use a for in both cases, or neither...
how about...
DataRow row, copy;
for (int i=0; i < myDataSet.MyTable.Rows.Count; i++) {
row = myDataSet.MyTable.Rows[i];
for (int j=i+1; j<copyDataSet.MyTable.Rows.Count; j++) {
copy = copyDataSet.MyTable.Rows[j];
//do your stuff...
}
}
depending on the actions being taken, a DataView is probably
a better option in any case...
Joe wrote:
Hi Antonio,
How about something like this?
int rowIdx = 0;
foreach (DataRow row in myDataSet.MyTable.Rows)
{
for (int r = rowIdx; r < copyDataSet.MyTable.Rows.Count; r++)
{
DataRow copiedRow = copyDataSet.MyTable.Rows[rowIdx];
// Do what you need
}
rowIdx ++;
}
-Joe
"Antonio Budano" <antonio.budano_REMOVE_THIS_@_REMOVE_THIS_poste.it > wrote
in message news:Oe*************@TK2MSFTNGP09.phx.gbl... Hi there,
How can I iterate through collections starting not from the first item but
from an offset?
I need to check if a dataset contains records that have some field values
that can conflict with some other records. So my code would be like the
following:
MyDataSet copyDataSet = new MyDataSet();
copyDataSet = myDataSet.Copy();
foreach(DataRow row in myDataSet.MyTable.Rows)
foreach(DataRow copyRow in copyDataSet.MyTable.Rows)
Do the records validation
the problem with this approach is that I will do checks twice, I need to
start iterating the copyDataSet.MyTable.Rows not from the first row but
from the row of myDataSet.MyTable.Rows + 1.
How can I achieve this?
--
Michael J. Ryan - tracker1(at)theroughnecks(dot)net -
www.theroughnecks.net
icq: 4935386 - AIM/AOL: azTracker1 - Y!: azTracker1 - MSN/Win: (email)