Foxtable(狐表)用户栏目专家坐堂 → [求助]如何得到不重复序列


  共有3680人关注过本帖树形打印复制链接

主题:[求助]如何得到不重复序列

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2015/2/23 10:19:00 [显示全部帖子]

 去重复?参考代码

 

Dim str As String = "2.4,1.7,1,1.2,1.2.3,1,1.2,1.2.4,1.7,2,2.8,2.8.1,2,2.8,2.8.1"
Dim ls As New List(Of String)
For Each s As String In str.Split(",")
    If ls.Contains(s) = False Then
        ls.Add(s)
    End If
Next
Dim ary As array = ls.ToArray
Array.Sort(ary)
output.show(String.Join(",", ary))


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2015/2/25 10:26:00 [显示全部帖子]

Dim str As String = "2.4,1.7,1,1.2,1.2.3,1,1.2,1.2.4,1.7,2,2.8,2.8.1,2,2.8,2.8.1"
Dim ls As New List(Of String)
For Each ss As String In str.Split(",")
    Dim temp As String = ""
    For Each s As String In ss.Split(".")
        temp = iif(temp = "", s, temp & "." & s)
        If ls.Contains(temp) = False Then
            ls.Add(temp)
        End If
    Next
Next
Dim ary As array = ls.ToArray
Array.Sort(ary)
output.show(String.Join(",", ary))

 回到顶部