I have the following:
DataTable table = new DataTable();
table.Columns.Add("id", typeof(string));
table.Columns.Add("date", typeof(DateTime));
DateTime date1 = new DateTime(2008, 3, 1, 7, 0, 0);
DateTime date2 = new DateTime(2007, 3, 1, 7, 0, 0);
DateTime date3 = new DateTime(2006, 3, 1, 7, 0, 0);
table.Rows.Add("123", date1);
table.Rows.Add("123", date2);
table.Rows.Add("ABC", date3);
I want to run an action that will delete all rows that have the same identifier as the other row, and save only one with the newest date.
In this small example, at the beginning I:
123 2008...
123 2007...
ABC 2006...
After the action, it should be:
123 2008...
ABC 2006...
How can I understand that?
(this is just a small example, my real data is much more)
source
share