Home All Groups Group Topic Archive Search About

Comparing values between two arrays

Author
23 Dec 2005 4:14 PM
darrel
I have two comma delimted strings that I need to compare individual values
between the two. I assume the solution is likely to put them into an array?
If so, do I need to loop through one, comparing the other, or is there some
sort of compare function already in .net?

For instance, I have these strings:

str1: ,3,6,12,17,

str2: ,7,8,12,

I need to check to see if any of the values in str1 exists in str2.

Off the top of my yead, I could split str2 into an array, then loop through
the values in the array using the instr function to see if they exist in
str1.

-Darrel

Author
23 Dec 2005 4:48 PM
Karl Seguin
there are a lot of ways to do this.  You could split on array loop through
it and look for a non-negative IndexOf of the value within the other string.

you could split both and loop through both

you could split them and load them in arraylists and use Contains (which
merely loops)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/


Show quote
"darrel" <notr***@nowhere.com> wrote in message
news:eYgQtv9BGHA.1676@TK2MSFTNGP09.phx.gbl...
>I have two comma delimted strings that I need to compare individual values
>between the two. I assume the solution is likely to put them into an array?
>If so, do I need to loop through one, comparing the other, or is there some
>sort of compare function already in .net?
>
> For instance, I have these strings:
>
> str1: ,3,6,12,17,
>
> str2: ,7,8,12,
>
> I need to check to see if any of the values in str1 exists in str2.
>
> Off the top of my yead, I could split str2 into an array, then loop
> through the values in the array using the instr function to see if they
> exist in str1.
>
> -Darrel
>
Author
23 Dec 2005 5:11 PM
darrel
> there are a lot of ways to do this.  You could split on array loop through
> it and look for a non-negative IndexOf of the value within the other
> string.
>
> you could split both and loop through both
>
> you could split them and load them in arraylists and use Contains (which
> merely loops)

Looping it is!

Just realized that it's not really that big of an issue. Split one of the
two, loop through the other comparing.

-Darrel

AddThis Social Bookmark Button