Remove equal lines from two textBox-es (c#)

  • Thread starter Thread starter nextb88
  • Start date Start date
N

nextb88

Guest
I have two textBox-es on the Form, textBox1.Text (multi-line) and textBox2.Text (multi-line).
(The text is loaded into textBox2.Text).

I would like to remove all the same lines which found in both textBox-es, but I want to remove those same lines only from textBox2.Text...

For example, if the contents of both textBox-es look like the image below before executing code:

1.png

After executing the code I would like it to look like the image below:

2.png

How can I do that. I ask for your help. Thank you.

I've tried something like the code below, but it's not good.
private void TextBox2_TextChanged(object sender, EventArgs e)
{
string[] lines = textBox1.Lines;
string[] lines1 = textBox2.Lines;
for (int i = 0; i < lines.Length; i++)
{
for (int j = 0; j < lines1.Length; j++)
{
if (textBox1.Lines == textBox2.Lines[j])
{
textBox2.Text = textBox2.Lines[j].Replace(textBox2.Lines[j], "");
}
}
}
}

Continue reading...
 
Back
Top