Arrays 如何获得两个二维数组之间的交集?
我想得到两个二维数组之间的交集,并将其作为一个二维数组返回,函数声明如下:Arrays 如何获得两个二维数组之间的交集?,arrays,vb.net,multidimensional-array,intersection,Arrays,Vb.net,Multidimensional Array,Intersection,我想得到两个二维数组之间的交集,并将其作为一个二维数组返回,函数声明如下: Private Function GetIntersection(ByVal Array2D1 As String(,), ByVal Array2D2 As String(,)) As String(,) 末级 Private Function GetIntersection(ByVal one As List(Of Pair), ByVal second As List(Of Pair)) As List(Of
Private Function GetIntersection(ByVal Array2D1 As String(,), ByVal Array2D2 As String(,)) As String(,)
末级
Private Function GetIntersection(ByVal one As List(Of Pair), ByVal second As List(Of Pair)) As List(Of Pair)
Dim intersection As New List(Of Pair)
If second.Count = 0 Then
second = one
End If
intersection = one.Intersect(second).ToList
Return intersection
End Function
您希望如何进行比较?a1(x,?)与所有a2(?),或a1(x,?)与a2(x,?)。例如:a1(0,0)={{“2”,“Name”}a1(0,1)={{“3”,“Name”}a2(0,0)={{“3”,“Name”}a2(0,1)={“3”,“Keyword”}。a1中也属于a2的所有元素(或等效地,a2中也属于a1的所有元素)然后,a3(0,0)={{“3”,“Name”}
Private Function GetIntersection(ByVal one As List(Of Pair), ByVal second As List(Of Pair)) As List(Of Pair)
Dim intersection As New List(Of Pair)
If second.Count = 0 Then
second = one
End If
intersection = one.Intersect(second).ToList
Return intersection
End Function