脑子不转了,请大家帮助arrayList 删除的问题
Dim arr As New ArrayList
arr.Add("aaaa")
arr.Add("bbb")
arr.Add("ccc")
Try
Dim cou As Integer = arr.Count - 1
For k = 0 To cou
Try
Dim s As String = arr.Item(k)
If s = "bbb" Then
arr.Remove(s)
‘请问再加什么才是正确的??
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
[解决办法]
Dim arr As New ArrayList Dim s As String = "ccc" arr.Add("aaa") arr.Add("bbb") arr.Add("ccc") For i As Integer = 0 To arr.Count - 1 If s = arr(i) Then arr.Remove(arr.Item(i)) Exit For End If Next For j As Integer = 0 To arr.Count - 1 Console.WriteLine(arr(j)) Next Console.ReadLine()
[解决办法]
循环新的list 根据新的list删除原来的list
[解决办法]
像这样的情况也还可以倒着来!