I have a text box that has each item on a new line. I am trying to remove duplicates from this textBox. I can't think of anything. I tried adding each item to an array and the removing the duplicates, but it doesn't work. Are there any other options?
yourTextBox.Text = string.Join(Environment.NewLine, yourArray.Distinct());
Building on what Anthony Pegram wrote, but without needing a separate array:
yourTextBox.Text = string.Join(Environment.NewLine, yourTextBox.Lines.Distinct());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With