gpt4 book ai didi

vb.net - 检查两个列表是否至少有一个共同项

转载 作者:行者123 更新时间:2023-12-04 04:48:26 26 4
gpt4 key购买 nike

如果有两个列表:

Dim list1 As New List(Of Integer)
list1.AddRange({1, 2, 3})

Dim list2 As New List(Of Integer)
list2.AddRange({1, 4, 5})

在 VB.NET 中,就性能而言,检测它们是否具有一个或多个公共(public)项的最佳方法是什么?这应该尽可能通用。

最佳答案

在 C# 中(但可能在 VB 中也有效)

list1.Intersect(list2).Any()

关于vb.net - 检查两个列表是否至少有一个共同项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17812042/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com