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
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top