Merging two arrays

  • Thread starter Thread starter ahmeddc
  • Start date Start date
A

ahmeddc

Guest
hi

I have an list string of names a.
and Another list string b with some names is very similar to the first list and its values.

I want if the name in the first list is in the second it will be added to a new array from listb
If the name in the first list is not present in the second, it is added to a new array from lista.

1603199.png

list a

Dim tmpLista As New List(Of String)
tmpLista.Add("STARTONE")
tmpLista.Add("man")
tmpLista.Add("spare")


list b

Dim tmpListb As New List(Of String)

tmpListb.Add("STARTONE:h5zgcw")
tmpListb.Add("spare:22h5zgcw")


listc i want

STARTONE:h5zgcw
man
spare:22h5zgcw


my error code

Dim tmpLista As New List(Of String)
tmpLista.Add("STARTONE")
tmpLista.Add("man")
tmpLista.Add("spare")

Dim tmpListb As New List(Of String)

tmpListb.Add("STARTONE:h5zgcw")
tmpListb.Add("spare:22h5zgcw")

Dim tmpListc As New List(Of String)
Dim a As String = ""
Dim b As String = ""
For Each valu As String In tmpLista
For Each x As String In tmpListb
a = x.Split(":").Last
b = x.Split(":").First
If x.Contains(valu) Then
tmpListc.Add(valu + ":" + a)

End If
Next
If Not valu.Contains(b) Then
tmpListc.Add(valu)

End If
Next

Continue reading...
 
Back
Top