How do I delete an element from an array

I have 2 arrays, FileList1 and FileList2. As I compare the 2, I want to delete any entries in FileList1 that are also in FileList2.

I found an answer at http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_23721653.html but I get the error "RemoveAt is not a member of System.Array"

It seems to have worked for a previous questioner so why not for me?

I am using Visual Studio Express 2008, (Visual Basic).
Dim FileList1(count1) As String ' Count1 is determined by some previous code
            Dim FileList2(count2) As String ' Count2 is determined by some previous code
 
            ' Code to populate the arrays
 
           If FileList1.Count > FileList2.Count Then
                For i As Integer = FileList1.Count - 1 To 0 Step -1
                    For x As Integer = FileList2.Count - 1 To 0 Step -1
                        If FileList2(x).ToString = FileList1(i).ToString Then
                            FileList1.RemoveAt(i)
                            Exit For 
                        End If
                    Next
                Next
            End If

Open in new window

LVL 1
jindaleeAsked:
Who is Participating?
 
Wayne Taylor (webtubbs)Connect With a Mentor Commented:
Consider using an ArrayList instead of Array. Then you can use the RemoveAt method.

Wayne
0
 
srikanthreddyn143Commented:
As Webtubbs said, Array is not resizable. You have to use arraylist to add or remove items dynamically.
0
 
p_davisCommented:
the asker in the pointer actually says that he has 2 arraylists.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
jindaleeAuthor Commented:
OOPS. So it does :S
0
 
srikanthreddyn143Commented:
Mr.jindalee,

the link you provided has used arraylist.I think you are using arrays.Right?
0
 
jindaleeAuthor Commented:
Haven't forgotten the question - I've been diverted to a higher priority task and haven't had the chance to try the suggestions. Will get back to it soon.
0
 
jindaleeAuthor Commented:
As soon as I changed from Array to ArrayList I was able to twek the code to do what I needed.

Thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.