Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have this set of this list.I have managed to add it inside the list and display it into a grid.

Now I would like to select the top 30 words inside the list. I am encountering some problems in doing so.

I would like to check the text that are typed into the textbox with the list and if the text already exist in the list, I would like to return the 30 words which includes the text.

Help needed.

Thanks in advance.

C#
string check = textbox.Text;

       <pre lang="xml">List<string> duplicate = new List<string>();

             if (duplicate.Contains(check) == true)
             {
                 int remove = Math.Max(0, duplicate.Count - 28);
                 duplicate.RemoveRange(0, remove);

                 duplicate.Insert(5, check);

                 //duplicate.AddRange(final);
             }</pre>
Posted

1 solution

Quote:
List<string> duplicate = new List<string>();
The above statement creates an empty list, that is duplicate contains NO items. You should use the List<T> Constructor (IEnumerable<T>)[^] ctor in order to make it a copy of the original one.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900