我知道我可以很容易地使用循环来完成这个,但我正在为我的问题寻找最有效的解决方案。
假设我有 2 个列表(字符串):
Dim lst1 as new list(of string)
Dim lst2 as new list(of string)
并且两者都具有相同数量的元素,例如:
Lst1: Lst2:
a abc1
a abc2
b abc3
a abc4
b abc5
c abc6
a abc7
c abc8
现在,例如,我正在寻找来自 lst2 的所有元素,其中 Lst1 = "a" 中的相应元素
所以我的最终结果将是:
Lst3 = Items from Lst2 where corresponding Items in Lst1 = "a"
Lst3 = {abc1, abc2, abc4, abc7}
再一次,我知道这对循环来说非常容易,但我想知道如何通过 Linq 做到这一点。
谢谢!!!