So I'm using ArrayLists to store some integer arrays and I came up with the following problem:
Public Class Form1
Public ag As New ArrayList
Sub a() Handles Me.Load
ag.Add(New Integer() {1, 2})
If ag.Contains(New Integer() {1, 2}) Then
MsgBox("aaa")
End If
End Sub
End Class
The MsgBox won't show although the ArrayList does contain "New Integer() {1, 2}", and even if I try this:
Public Class Form1
Public ag As New ArrayList
Sub a() Handles Me.Load
ag.Add(New Integer() {1, 2})
Dim t = New Integer() {1, 2}
For Each it In ag
If it.Equals(t) Then
MsgBox("aa")
Exit For
End If
Next
End Sub
End Class
It won't show at all.
Thanks in advance.
---------------EDIT---------------
I finally decided to just compare the values of the Integer lists like this:
Public Class Form1
Public ag As New List(Of Integer())
Sub a() Handles Me.Load
ag.Add(New Integer() {1, 2})
Dim t = New Integer() {1, 2}
For Each it In ag
If it(0) = t(0) And it(1) = t(1) Then
MsgBox("aa")
Exit For
End If
Next
End Sub
End Class
Thank you all for your replies.
New Integer() {1, 2}creates a new array