首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

2个ListBox如何比较项内容

2012-12-23 
2个ListBox怎么比较项内容?我想ListBox3添加 ListBox1不包含的ListBox项的‘杀星’。这个要怎么比较? for (in

2个ListBox怎么比较项内容?
2个ListBox如何比较项内容
我想ListBox3添加 ListBox1不包含的ListBox项的‘杀星’。这个要怎么比较?
 for (int j = 0; j < this.listBox1.Items.Count; j++)
            { 
                for (int i = 0; i < this.listBox2.Items.Count; i++) 
                {
                    if (listBox1比较ListBox)
                    {
                        this.listBox4.Items.Add....
                    }
                } 
            }
[解决办法]

foreach (var each in this.listBox1.Items) {
foreach (var eac in this.listBox2.Items) {
if(each.ToString()!=eac.ToString())
this.listBox3.Items.Add(eac.ToString());
}
}

热点排行