从数字字符串中检索唯一值 [英] retrieve unique values from string of numbers
本文介绍了从数字字符串中检索唯一值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个字符串
Dim test As String = "12,32,12,32,12,12,32,15,16,15,14,12,32"
并且想要检索一个字符串
and want to retrieve a string
newstr = 12,32,15,16,14
我试了这么多
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
只有唯一的数字我怎么能在 vb asp.net 中做到这一点
only unique numbers how can i do that in 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)
推荐答案
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()
这篇关于从数字字符串中检索唯一值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文