I am new to working with C# and databases.
I need to iterate over a Datatable (contained in a dataset) when I am iterating, I might need to compare the values from the current row with those from the previous row or next row.
I am currently iterating like this:
foreach(DataRow dr in ds.Tables["Invoices"].Rows)
{
//Check if invoice id is equal to invoice id from previous/next row
}
One way I can think of is to maintain “prev” variables to store the old value and compare and update as go along but I wanted to see if the DataTable offered any built in options.
Thanks,
Calvin
1 Answer