C# Wpf list 前移后移一个元素的操作
//List 向后移动一个元素 private void MoveBehindUtilityDataList(List<T> UtilityRecordList, int MoveIndex, T MovedData) { T Current, tmp; tmp = T[MoveIndex]; for (int i = MoveIndex; i < UtilityRecordList.Count - 1; i++) { Current = tmp; tmp = UtilityRecordList[i + 1]; UtilityRecordList[i + 1] = Current; } UtilityRecordList[MoveIndex] = MovedData; return; } //List 向前移动一个元素 private void MoveFrontUtilityDataList(List<T> UtilityRecordList, int MoveIndex, T MovedData) { for (int i = MoveIndex + 1; i < UtilityRecordList.Count; i++) { UtilityRecordList[i - 1] = UtilityRecordList[i]; } UtilityRecordList[UtilityRecordList.Count - 1] = MovedData; return; }