I'm developing on a more or less legacy C# application and stumbled upon a code that I wrote some time ago. But somehow I get the feeling, that this is not really a good approach to this.
How would I make this code better?
public static void RemoveEntries(DataTable source, ref DataTable destination, int indexSource, int indexDestination)
{
var arVals = new int[source.Rows.Count];
var i = 0;
foreach (DataRow sourceRow in source.Rows)
{
if (sourceRow.RowState != DataRowState.Deleted)
arVals.SetValue(sourceRow[indexSource], i);
i += 1;
}
foreach (
var destinationRow in
from DataRow row3
in destination.Rows
where arVals.Contains((int) row3[indexDestination])
where row3.RowState != DataRowState.Deleted
select row3
)
destinationRow.Delete();
}
Thanks in advance, bb