Dim l As New List(Of Integer)(New Integer() {1, 2, 0, 3, 0, 4})
l.RemoveAll(Function(x) x = 0)
Dim l As New List(Of Integer)(New Integer() {1, 2, 0, 3, 0, 4})
l.RemoveAll(AddressOf RemoveZeros)
Private Function RemoveZeros(ByVal x As Integer) As Boolean
If x = 0 Then
Return True
Else
Return False
End If
End Function
Dim a() As Integer = {1, 2, 0, 3, 0, 4}
Dim tempList As New List(Of Integer)(a)
tempList.RemoveAll(AddressOf RemoveZeros)
a = tempList.ToArray
Correct, I didn't notice that.MattP said:he's marked as using .Net 2.0 and won't be able to use the lambda.
Private Function RemoveZeros(ByVal x As Integer) As Boolean
If x = 0 Then
Return True
Else
Return False
End If
End Function
Private Function RemoveZeros(ByVal x As Integer) As Boolean
Return x = 0
End Function
No, you can add the array to the list as shown with the constructor, or using the AddRange method, and continue working from there. You should also revaluate if using array in the first place is necessary, usually collections is the way to go, it's just a simplification of common array operations and includes memory optimizations. For example thelist.Sort does the same as Array.Sort(thearray).Thing is, I have this array already established and have done some operations on it like sorting and using ubound on it, I think re defining as a list would cause it to break?