I have a text box in which there is every element of a new line. I am trying to remove duplicates from this text box. I can’t think of anything. I tried to add each element to the array and remove duplicates, but it does not work. Are there any other options?
yourTextBox.Text = string.Join(Environment.NewLine, yourArray.Distinct());
Based on what Anthony Pegham wrote, but without a separate array:
yourTextBox.Text = string.Join(Environment.NewLine, yourTextBox.Lines.Distinct());
public static string[] RemoveDuplicates(string[] s) { HashSet<string> set = new HashSet<string>(s); string[] result = new string[set.Count]; set.CopyTo(result); return result; }
.
Source: https://habr.com/ru/post/1782974/More articles:What version of OpenGL is installed by default with MinGW? - openglОператоры присвоения Ruby - rubyRun the wsgi application from virtualenv as a Linux system service - pythonjQuery ajax: before event - javascriptOpen iCal for a specific CalEvent with Objective-C - cocoaplugin for plugins vs jQuery - jqueryCustom grid LINQ to SQL - c #How to extract values from a JSON Search Search API page using PHP? - jsonKynetx vs Site Tags plugin - How can I tell the difference? - krlTypeError: Error # 2007: child must not be null - actionscript-3All Articles