gpt4 book ai didi

c# - 从列表框中搜索和删除项目

转载 作者:太空宇宙 更新时间:2023-11-03 18:00:58 24 4
gpt4 key购买 nike

有没有办法根据字符串从列表框中删除项目?

我已经玩了几分钟,这是我目前所拥有的,但它不起作用

foreach(string file in LB_upload.Items)
{
ftp.Upload(file);
int x = LB_upload.Items.IndexOf(file);
LB_upload.Items.RemoveAt(x);
}

我可以循环遍历每个项目,但我想做一些更优雅的事情

最佳答案

while(LB_upload.Items.Count > 0)
{
ftp.Upload(LB_upload.Items[0].ToString());
LB_upload.Items.RemoveAt(0);
}

关于c# - 从列表框中搜索和删除项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1400091/

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