Comparing values between two arrays


D

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
 
Ad

Advertisements

K

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
 
Ad

Advertisements

D

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
 

Top