/// <summary> /// Removes rows with duplicate MessageIDs. /// </summary> /// <param name="thanksData">The thanks data.</param> private void DistinctMessageID(EnumerableRowCollection <DataRow> thanksData) { int previousId = 0; int tempId; foreach (var dr in thanksData.OrderBy(x => x.Field <int>("MessageID"))) { tempId = dr.Field <int>("MessageID"); if (dr.Field <int>("MessageID") == previousId) { dr.Delete(); } previousId = tempId; } }