从数字字符串中检索唯一值

use*_*110 -1 vb.net

我有这个字符串

 Dim test As String = "12,32,12,32,12,12,32,15,16,15,14,12,32"
Run Code Online (Sandbox Code Playgroud)

并想要检索一个字符串

newstr = 12,32,15,16,14
Run Code Online (Sandbox Code Playgroud)

我试过这么多

Dim test As String = "12,32,12,32,12,12,32,15,16,15,14,12,32"
Dim word As String
Dim uc As String() = test.Split(New Char() {","c})
For Each word In uc
' What can i do here?????????
Next
Run Code Online (Sandbox Code Playgroud)

只有唯一的数字我怎么能在vb asp.net中做到这一点

正确答案

Dim test As String = "12,32,12,32,12,12,32,15,16,15,14,12,32"
                Dim word As String
                Dim uc As String() = test.Split(New Char() {","c}).Distinct.ToArray
                Dim sb2 As String = "-1"
                For Each word In uc
                    sb2 = sb2 + "," + word
                Next
                MsgBox(sb2.ToString)
Run Code Online (Sandbox Code Playgroud)

Nar*_*iya 6

Dim test As String = "12,32,12,32,12,12,32,15,16,15,14,12,32"
Dim uniqueList As String() = test.Split(New Char() {","c}).Distinct().ToArray()
Run Code Online (Sandbox Code Playgroud)