合并list<string>
时间: 2023-11-10 21:16:57 浏览: 90
C语言写的合并链表——CreateMergeList
要合并两个List<string>并去除重复项,可以使用AddRange方法将一个List添加到另一个List中。然后可以使用Distinct方法去除重复项。以下是一个示例代码:
List<string> list1 = new List<string>();
List<string> list2 = new List<string>();
list1.Add("FUCK");
list1.Add("lb");
list1.Add("sorr");
list2.Add("FUCK");
list2.Add("12");
list1.AddRange(list2);
list1 = list1.Distinct().ToList();
这样,list1中就是合并后去除重复项的结果。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [C# 合并多个 list<string>](https://blog.csdn.net/qq_40267217/article/details/80626081)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [List合并的5种方式,以及它的速度比较](https://blog.csdn.net/qq_34699995/article/details/114696891)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文