Home All Groups Group Topic Archive Search About

comparing values in ARRAYLISTS

Author
2 Aug 2006 7:58 AM
steve
I need to compare the value of a field in a row on an arraylist with the value of a field on a second arraylist
I have this bit of code working for arrays but cant get it working for arraylists
The secone argument here (1) represents the second field in the row, with arraylists I get a message saying to many arguments.

Can I do this with arraylists or do I need to copy the arraylists to arrays?

Thanks
  For q As Integer = 0 To 9

            For j As Integer = 0 To 9



                If StrArray1(q, 1) = StrArray2(j, 1) Then

                    count = count + 1
                End If

            Next
        Next
From http://www.developmentnow.com/g/38_0_0_0_0_0/dotnet-languages-vb.htm Posted via DevelopmentNow.com Groups http://www.developmentnow.com

Author
2 Aug 2006 9:07 AM
tommaso.gastaldi
hi steve, in theory you could do an arraylist of arraylists.

but... I would think twice before implementing something
like that, with quadratic complexity.

Probably there are more efficient way to organize
your class and data structures in order to avoid that.

-tom

steve ha scritto:

Show quoteHide quote
> I need to compare the value of a field in a row on an arraylist with the value of a field on a second arraylist
> I have this bit of code working for arrays but cant get it working for arraylists
> The secone argument here (1) represents the second field in the row, with arraylists I get a message saying to many arguments.
>
> Can I do this with arraylists or do I need to copy the arraylists to arrays?
>
> Thanks
>   For q As Integer = 0 To 9
>
>             For j As Integer = 0 To 9
>
>
>
>                 If StrArray1(q, 1) = StrArray2(j, 1) Then
>
>                     count = count + 1
>                 End If
>
>             Next
>         Next
>
>
> From http://www.developmentnow.com/g/38_0_0_0_0_0/dotnet-languages-vb.htm
>
> Posted via DevelopmentNow.com Groups
> http://www.developmentnow.com
Author
2 Aug 2006 1:45 PM
stefano
Author
2 Aug 2006 2:58 PM
tommaso.gastaldi
ah sei italiano :)

if you describe you original problem, perhaps I or other people here
can
be of help to reorganize your code. Keep in mind that multidimensional
arrays are quite inefficient in .NET and they can be usually replaced
with more efficient
objects based on unidimensional collections.

tommaso

stefano ha scritto:

Show quoteHide quote