For循环不给点数集合添加值。

问题描述 投票:0回答:1

for循环并没有给我的积分收集增加任何价值。

Esri.ArcGISRuntime.Geometry.PointCollection VMM40Points = new Esri.ArcGISRuntime.Geometry.PointCollection(Spatialreference);
            for (int i = 1; i == xyz.Count/3; i += 3)
            {
                VMM40Points.Add(xyz[i - 1], xyz[i], xyz[i + 1]);
            }

这是调试器。https:/i.stack.imgur.com7ZXwA.png。

c# for-loop arcgis
1个回答
2
投票

for循环的 "while "部分是不正确的:它运行的是 条件是真的,而不是 直到.

我不知道为什么你有 [i -1]. 是否有特殊原因?如果没有,你把循环条件弄得比必要的复杂多了。

var VMM40Points = new Esri.ArcGISRuntime.Geometry.PointCollection(Spatialreference); 
for (int i = 0; i < xyz.Count; i+=3)
{
    VMM40Points.Add(xyz[i], xyz[i + 1], xyz[i + 2]);
}

0
投票

将你的条件改为 i < xyz.Count/3.

© www.soinside.com 2019 - 2024. All rights reserved.