static void Move(IList <object> List, int moveFromIndex, int moveToIndex) { if (ListExtensions.CheckIndex(moveFromIndex, List) && ListExtensions.CheckIndex(moveToIndex, List)) { var targetRecord = List[moveToIndex]; List[moveToIndex] = List[moveFromIndex]; List[moveFromIndex] = targetRecord; } }
public static void Move <T>(IList <T> List, int moveFromIndex, int moveToIndex) where T : CRUDObject { if (ListExtensions.CheckIndex(moveFromIndex, List) && ListExtensions.CheckIndex(moveToIndex, List)) { var targetRecord = List[moveToIndex]; var targetSortIndex = targetRecord.SortIndex; var sortIndex = List[moveFromIndex].SortIndex; List[moveToIndex] = List[moveFromIndex]; List[moveToIndex].SortIndex = targetSortIndex; List[moveFromIndex] = targetRecord; List[moveFromIndex].SortIndex = sortIndex; } }