如何比较两个不同的arraylist值? [英] How to compare two different arraylist values?
本文介绍了如何比较两个不同的arraylist值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在vb.net/c#中比较2个不同的arraylist?
例如:
Hi,
How to compare 2 different arraylist in vb.net/c#?
Example:
List1: List2:
SNo. Address SNo. Address
1 AAAAA 1 BBBBB
2 BBBBB 2 CCCCC
3 CCCCC 3 DDDDD
Expected Results:
SNo Address
1. AAAAA -----> This row is define Red color,(Because not in List2)
2. BBBBB -----> This row is define Green color(Because it contains both Lists)
3. CCCCC -----> This row is define Green color(Because it contains both Lists)
4. DDDDD -----> This row is define Blue color(Because not in List1)
先谢谢。
Thanks in Advance.
推荐答案
var onlyinfirst = from s in list1 where !list2.Contains(s) select s;
var onlyinsecond = from s in list2 where !list1.Contains(s) select s;
var onboth = from s in list1 where list2.Contains(s) select s;
这篇关于如何比较两个不同的arraylist值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文