gpt4 book ai didi

c# - 在 foreach 循环中删除列表中的项目 C#

转载 作者:太空狗 更新时间:2023-10-30 00:50:17 25 4
gpt4 key购买 nike

<分区>

如果我在 foreach 循环中使用一个项目,但我不能使用该项目,它必须删除当前在 foreach 循环中的项目。

这是我现在拥有的代码:

foreach (Line line in linelijst)
{
try
{
if (line.ActorIndex() == 0)
{
line.setStartPoint(actorenlijst[0].getLinePoint()); //if actorenlijst[0] doesn't excist it has to delete the current line
}
if (line.ActorIndex() == 1)
{
line.setStartPoint(actorenlijst[1].getLinePoint()); //if actorenlijst[1] doesn't excist it has to delete the current line
}
if (line.ActorIndex() == 2)
{
line.setStartPoint(actorenlijst[2].getLinePoint()); //if actorenlijst[2] doesn't excist it has to delete the current line
}
Point start = line.getStartPoint();
Point end = line.getEndPoint();
Pen lijn = new Pen(Color.Black, 1);
graphics.DrawLine(lijn, start, end);
}
catch
{
//delete current line from the list
}
}

感谢您有兴趣帮助其他人:)

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com