Link to home
Start Free TrialLog in
Avatar of shragi
shragiFlag for India

asked on

arraylist comparison

I had an arraylist with values

DOCX
DOC
DOCX
DOC
DOC
DOC

I want to check whether all the values in the arraylist are equal or not

here the arraylsit values are different (4 DOC 2 DOCX) if different i want to set a flag to false
else set flag to true.

Avatar of kaufmed
kaufmed
Flag of United States of America image

It should be something along the lines of:
Dim baseLine As String = yourArrayList(0).ToString()
Dim allEqual As Boolean = True

For Each item In yourArrayList
    If item.ToString() <> baseLine Then
        allEqual = False
        Exit For
    End If
Next

If allEqual Then
    MessageBox.Show("All items are equal")
Else
    MessageBox.Show("All items are NOT equal")
End If

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Shahan Ayyub
Shahan Ayyub
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial