可以使用以下方法去除重復數據:
Dim arr() As Integer = {1, 2, 3, 3, 4, 5, 5}
Dim list As New List(Of Integer)
For Each num As Integer In arr
If Not list.Contains(num) Then
list.Add(num)
End If
Next
arr = list.ToArray()
Dim arr() As Integer = {1, 2, 3, 3, 4, 5, 5}
Dim set As New HashSet(Of Integer)
For Each num As Integer In arr
set.Add(num)
Next
arr = set.ToArray()
這兩種方法都可以去除數組中的重復數據,選擇哪一種方法取決于你對List或HashSet的偏好。