Click here to Skip to main content
15,881,967 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
Hi,

I have a List<string>. Inside it I have a collection of string texts.

I would like to manipulate the list into delete all the text except the text that have been typed into the textbox.

How do I do that?

Help needed. Thanks in advance.

XML
List<string> final = new List<string>();
                foreach (KeyValuePair<string, int> entry in sortDict)
                    final.Add(entry.Key);
                final.RemoveAt(2);

                List<string> duplicate = final.ToList();

                //string check = textbox1.Text;

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

                    int delete = Math.Max(0, duplicate.Count - 3);
                    duplicate.RemoveRange(3, delete);

                    // delete all the text in the string except check

                    duplicate.AddRange(final);
                }
Posted
Comments
Prasad Avunoori 7-May-14 5:58am    
Not clear.

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