【发布时间】:2021-04-13 16:55:56
【问题描述】:
如果 list1 中的字符串(或字符串的一部分)与 list2 中的字符串相同,则需要将字符串添加到列表框中。
我现在有:
int g = 0;
while (g < musthaves.Count())
{
if (list1.Contains(list2[g].ToString()))
{
listBox14.Items.Add("Found: " + list2[g].ToString());
}
else
{
listBox14.Items.Add("Not found: " + list2[g].ToString());
}
g++;
}
名单如下:
列表1:
测试用例扫描文档
测试用例上传文件
测试用例删除文档
列表2:
上传文件
扫描文件
表示不一致
所以列表框应该包含:
找到:上传文件
找到:扫描文档
未找到:表示不一致
但我的结果不是每个字符串都找到。
感谢任何帮助。
【问题讨论】:
标签: c# if-statement while-loop contains