简体   繁体   English

For 循环不会将值添加到点集合

[英]For loop doesn't add values to a points collection

The for loop doesn't add any value to my points collection: 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]);
            }

this is the debugger: https://i.stack.imgur.com/7ZXwA.png这是调试器: https://i.stack.imgur.com/7ZXwA.png

The "while" portion of the for loop was incorrect: it runs while the condition is true, not until . for 循环的“while”部分不正确:它在条件为真时运行,而不是直到

I'm not sure why you have [i -1] .我不确定你为什么有[i -1] Is there a special reason?有什么特殊原因吗? If not, you are making the loop conditions much more complicated than necessary.如果不是,那么您会使循环条件变得比必要的复杂得多。

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]);
}

Change your condition to i < xyz.Count/3 .将您的条件更改为i < xyz.Count/3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM