arraylist X2 - filter out items

web_dev_2010

New member
Joined
Oct 19, 2010
Messages
2
Programming Experience
3-5
Hi Guys
This is bugging (my head is now switched off).
I have two array's, one populated with dynamic elements and the other with static values. I am trying to filter out the values that i dont want from one of the arrays:

Dim arrFormItems As New ArrayList
arrFormItems.AddRange(arrSplitValues)

Dim arrItemsRemove As New ArrayList
arrItemsRemove.Add("__VIEWSTATE")
arrItemsRemove.Add("__EVENTVALIDATION")
arrItemsRemove.Add("__LASTFOCUS")
arrItemsRemove.Add("__EVENTVALIDATION")

For i As Integer = (arrFormItems.Count - 1) To 0 Step -1
For j As Integer = (arrItemsRemove.Count - 1) To 0 Step -1
If arrItemsRemove(j) = arrFormItems(i) Then
arrItemsRemove.RemoveAt(i)
End If
Next
Next

Dim arrrtnResults() As String = arrItemsRemove.ToArray(GetType(String))
For Each item As String In arrrtnResults
rtnValues.AppendLine(item.ToString & "<br/>")
Next

Return rtnValues.ToString

No matter what i do, i cant filter out the values. Tried the compare method as well..

Any ideas on what i am doing wrong?

Thanks in advance.
 
should also mention if there is a better way (generics, collections etc) please advise. Open to suggestions and examples.

basically if the value matches the arrItemsRemove value, i dont want that value addedd to the arrrtnresults. had a look around for some examples, but its like searching for a needle in an haystack.
cheers guys.
 
Back
Top