Im trying to write a simple program that will take 2 multi line inputs from 2 textboxes, put them in 2 arrays and compare them.
I want to check if an entry in array 1 (each line of textbox 1 is a separate entry in array 1) is in array 2 (each line of text box 2 is a separate entry in array 2).
then output the results to a textbox.
for example:
Array 1 "one, two, three, four, six"
Array 2 "one, three, five, four"
it should output:
one = found
two = not found
three = found
four = found
six = not found
The code i have so far is as follows:
private void button1_Click(object sender, EventArgs e)
{
textBox3.Text = "";
string[] New = textBox1.Text.Split('\n');
string[] Existing = textBox2.Text.Split('\n');
//for each line in textbox1's array
foreach (string str in New)
{
//if the string is present in textbox2's array
if (Existing.Contains(str))
{
textBox3.Text = " ##" + textBox3.Text + str + "found";
}
/if the string is not present in textbox2's array
else
{
textBox3.Text = " ##" +textBox3.Text + str + "not found";
}
}
}
This is not working correctly if there is more than one line in the either textbox - i cant figure out why.. the following is happening in test runs:
Array 1 - "One"
Array 2 - "One"
Result = One Found
Array 1 - "One"
Array 2 - "One, Two"
Result = One Not Found
Array 1 - "One, Two"
Array 2 - "One, Two"
Result = One found, Two Found
Array 1 - "One, Two, Three"
Array 2 - "One, Two"
Result - One Found, Two Not Found, Three Not Found
Thanks in advance

textBox1.TextandtextBox2.Textare?