我正在尝试从我的数组中获取点之间的路径。例如,当它在两点之间获得路线时;
getRoute(array[0],array[1])
之后,我想删除array[0]
项并检查array[1]
和其他数组项之间的路由。我怎样才能做到这一点 ?
答案 0 :(得分:1)
// Route is the custom class that your getRoute-method returns.
var routes = new List<Route>();
for (int i = 0; i < array.Length - 1; i++)
{
routes.Add(getRoute(array[i], array[i + 1]));
}
好的,根据下面的评论,也许这就是你想要的?
var sequence = new int[] { 0, 3, 1, 4, 8 };
// Route is the custom class that your getRoute-method returns.
var routes = new List<Route>();
for (int i = 0; i < sequence.Length - 1; i++)
{
routes.Add(getRoute(array[sequence[i]], array[sequence[i + 1]]));
}