【发布时间】:2013-11-23 17:12:42
【问题描述】:
我正在使用ForEach statement 将属性值分配给一个类。输出将如下所示...
Startingpoint | length
-----------------------
0 | 1
1 | 54.47
55.47 | 47.98
所以长度是这样计算的……
length = *next item starting point - current item starting point
这就是我想以伪代码式的外观做的事情。
foreach (DefectMap obj in dm)
{
mdmList.Add(new ModifiedDefectMap()
{
StartingPoint = obj.Start,
Length = ValueOfNext().obj.Start - obj.Start
问题是,我无法知道"ValueOfNext().obj.Start" 会是什么,因为我正在foreach 循环的当前迭代中。
【问题讨论】:
-
1. option - 使用 for 循环 2. option - 使用
indexof -
我已经稍微修正了格式。希望你不介意
标签: c# loops foreach iteration