【发布时间】:2019-09-27 15:14:06
【问题描述】:
我有一些图像滑块,我想更改图像滑块的顺序。当前序列是从数据库字段中设置的(从数据库中获取序列号集并显示它)。
现在,我想更改序列号。可以说,
我的滑块序列是 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 并且我需要将第 4 个位置的滑块更改为第 8 个位置,之后我的滑块编号序列是 1, 2, 3, 5, 6, 7, 4, 8, 9, 10。
我有一个具有当前序列的 int 数组,
int[] currentSequence = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
我的代码:
int[] currentSequence = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
var currentPosition = iproductrepositroy.GetSingle(x => x.ProductName.Equals(ProductName)).ProductSequence;// 4th position
var expectedPosition = ChangeSequence;// 8th position
if (currentPosition < expectedPosition)//right shift -->
{
int i = 0;
for (i = (int)currentPosition + 1; i < expectedPosition; i++)
{
// I wanted to know how to change the above array here
}
}
else//left shift <--
{
int i;
for (i = (int)currentPosition - 1; i > expectedPosition; i--)
{
}
}
【问题讨论】: