0

i have this Visual Basic .NET ArrayList

Dim first As New ArrayList()

            first.Add({100, 200})
            first.Add({500, 250})
            first.Add({700, 200})

My question is, how i can get True from this code...

first.Contains({500, 250})

Always return me False... what is the correct syntax?

1 Answer 1

3

Contains proves if the object you pass in is already in the ArrayList. It does not compare your values.

Sample:

Imports System

Public Class Sample

    Sub Method()
        Dim Obj1 As New Object()
        Dim Obj2 As New Object()
        Console.WriteLine(Obj1.Equals(Obj2)) '===> false
        Obj2 = Obj1
        Console.WriteLine(Obj1.Equals(Obj2)) '===> true
    End Sub 'Method 
End Class 'Sample

Here Obj1 und Obj2 are both of type Object but they are not equal even if their internal object state might be the same.

You might write your own custom class implementing IComparable to achieve want you want.

Sign up to request clarification or add additional context in comments.

1 Comment

Any other fast solution? my intention is use it only to remove the not Containing values from the arraylist.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.