473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Comparing values between two arrays

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
Dec 23 '05 #1
2 2037
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/
"darrel" <no*****@nowhere.com> wrote in message
news:eY**************@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

Dec 23 '05 #2
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
Dec 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jorgen Gustafsson | last post by:
Hi, im trying to write a small progam to compare data in 2 textfiles. I want to search for values that doesnt exist in File2. The result should be "3" in the example below but Im not able to do...
6
by: Raistlin | last post by:
Hey, for c++ does any body have a way to compare two arrays? Say one has the numbers 1-5000, the other has *most* of the numbers from 1-5000, is there a way to display the numbers that are in the...
1
by: Iain | last post by:
Hi Hopefully I am missing something really simple with this question, but here goes. I have two Bitarrays that I would like to compare. At the moment, I am XORing one with the other and...
12
by: Elijah Bailey | last post by:
I have two char arrays of size k. I want to know which one is bigger (exactly like for instance I compare two ints/longs/etc.). What is the fastest way to do this? k <= 10 usually for my...
19
by: Ole Nielsby | last post by:
How does the GetHashCode() of an array object behave? Does it combine the GetHashCode() of its elements, or does it create a sync block for the object? I want to use readonly arrays as...
1
by: psmahesh | last post by:
Hi folks, I am comparing two arrays and removing matches from the second array from the first array. Can someone take a look at this code below and mention if this is okay and perhaps if there...
1
by: Adrienne Boswell | last post by:
I have a form which I am letting the user enter more than one event at a time. I need to check whether one date is less than another. If the display to date is earlier than the event date, then...
1
by: chiefychf | last post by:
I'm working on a school project and I am having a few issues... The program calls for three arrays a,b,c that have to be sorted, then compared to even or odd and stored in arrays d & e, then merge...
3
by: =?Utf-8?B?Sm9zaFA=?= | last post by:
Hi All, I am attempting to compare values in two arraylists to make sure all the values are the same. I am running into trouble with my code if both arraylists compare okay up until a point and I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.