I have a DataTable in my C#/WPF application which is used to bind results information and show it to the user. The application is asking the core every once in a while for its results, and updates its own table accordingly. The code is:
int selfCount = Table.Rows.Count;
int totalCount = result.ResultsTable.Rows.Count;
for (int i = selfCount; i < totalCount; i++)
Table.LoadDataRow(result.ResultsTable.Rows[i].ItemArray, true);
I was wondering whether it’s good practice, or is
Table.Rows.Add(result.ResultsTable.Rows[i].ItemArray);
a better idea:
- I don’t care if the same line is added again and again (the results are defined by the user).
- Using
LoadDataRowcauses the app to iterate over the current table for each row of the new table, isn’t it?
The only possible problem I can see is in case Rows.Add doesn’t add the new row at the bottom. Can this happen?
Actually,
would be the ideal candidate AFAIK.