以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  【求助】字符串处理相关的问题?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=134005)

--  作者:gaojianwu
--  发布时间:2019/4/25 10:45:00
--  【求助】字符串处理相关的问题?
已知"a|b|c", "b|c|d", "d|e|f",怎么通过代码将这三个合并得到"a|b|c|d|e|f"?
--  作者:linyunu
--  发布时间:2019/4/25 12:54:00
--  
Dim a As String = "a|b|c"
Dim b As String = "b|c|d"
Dim c As String = "d|e|f"
Dim z As String
Dim a1() As String = a.Split("|")
For i As Integer = 0 To a1.Length - 1
    If b.Contains(a1(i))=False And c.Contains(a1(i))=False Then
        If z = "" Then
            z = a1(i)
        Else
            z += "|" & a1(i)
        End If
    End If
Next
Dim b1() As String = b.Split("|")
For o As Integer = 0 To b1.Length - 1
    If c.Contains(b1(o))=False Then
        z += "|" & b1(o)
    End If
Next
Output.Show(z & "|" & c)

求更简单更简洁的代码!

--  作者:有点甜
--  发布时间:2019/4/25 13:00:00
--  
Dim a As String = "a|b|c"
Dim b As String = "b|c|d"
Dim c As String = "d|e|f"
Dim ls As new List(of String)
Dim arys() = {a, b, c}
For Each ary As object In arys
    For Each s As String In ary.split("|")
        If ls.Contains(s) = False Then
            ls.add(s)
        End If
    Next
Next
msgbox(String.join("|", ls.ToArray))

--  作者:linyunu
--  发布时间:2019/4/25 13:52:00
--  
学习了