hye everyone i have some problem with coding. The problem is i have two data which is need to be compared for matching item and there is some of the data have duplicates and i did not want to remove the duplications, the part of the data is divided by an empty space. What i need is to compare the data symmetricaly.
The test data is like this:-

Data 1:
A

B
C
D

Data 2:
A
Q
C

B
C
D

the result suppose to be :
A is match
Q is not match
C is not match

B is match
C is match
D is match

what i get for the result is :

A is match
Q is not match
C is match

B is match
C is match
D is match

``````bool found = false;
foreach (string str in list2.ToList())
{
foreach (string str2 in list.ToList())
{
if(!str2.Equals(""))
{

if (str.Equals(str2))
{
found = true;
listBox1.Items.Add(str2 + " and " + str + " MATCH ");
break;
}

}

else
{
if (str.Equals(""))
found = false;
}

}

if (!str.Equals(""))
{
if (found == false)
{
listBox1.Items.Add(str + " NOT MATCH ");
}
}

else
found = false;
}``````

Looking at your data I interpret it as being lists of lists. Data Set 1 consists of two lists

``````A
B C D``````

Data Set 2 consists of two lists

``````A Q C
B C D``````

So break your problem down. Instead of comparing two Data Sets you are comparing lists of lists. In pseudo code

``````Do until no more lists

get list from Data Set 1
get list from Data Set 2
compare the lists

loop``````

To compare the lists you just step through both lists together (stopping when one list is exhausted) and compare elements at the same position. You can write a function that returns a list from a data set, or some value that indicates there are no more lists.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.