Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这个问题:
List<string> a = {"aa","aaa","aaaa"} List<string> b = {"bb","bbb","bbbb"}
我做了a.AddRange(b),并且在我需要从列表 a 中提取列表 b 之后,让它就像开始一样,具有相同的元素。我怎样才能做到这一点?
a.AddRange(b)
您总是可以遍历列表 b,并从列表 a 中删除每个项目:
b.ForEach(item => a.Remove(item));