本文介绍了Vb.net 如何从数组中删除重复项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Dim ItemList As New ArrayList()
For i = 0 To dgExtract.Items.Count - 1
gRow = dgExtract.Items(i)
chk = gRow.FindControl("chkSelect")
If chk.Checked Then
sEmail = gRow.Cells(7).Text
dim number as string = Regex.Replace(sEmail,"[^0-9]","")
if number.length = 11 then
ItemList.Add(number)
end if
end if
Next
我用上面的代码建立了 ItemList 数组.如何删除此数组中的任何重复项?
I build up the ItemList array with the above code. How do i remove any duplicates in this array?
推荐答案
设置:
Dim number As Integer
Dim num As String
Dim al As New ArrayList()
If Not (al.Contains(number)) Then
al.Add(number)
End If
获取:
For Each number In al
num = number.ToString()
Next
这篇关于Vb.net 如何从数组中删除重复项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!