Delete words from list in c# | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Delete words from list in c#

Guys i have problem to removing item from generic list in c# I have generic list contains words from text file. The text file is paper that i downloaded from scholar.Google.Com I want to delete all "THE" words from this list there is 65 "THE" in this file how do you suggest to delete them from list??

10th Apr 2017, 9:37 PM
prg_Mohamad
prg_Mohamad - avatar
3 Answers
+ 21
u can make another list and copy all != the words there or while making list insert only != the words
10th Apr 2017, 9:56 PM
Illusive Man
Illusive Man - avatar
+ 6
wordlist.Sort(); int start= wordlist.IndexOf("THE"); int end= wordlist.LastIndexOf("THE"); wordlist.RemoveRange(start, end);
10th Apr 2017, 10:01 PM
Daniel Thomalla
Daniel Thomalla - avatar
0
Tnx i did this with lambda expersions like this List. Removeall(d1=>d1. Equals("the") ) ; I dont know its correct or not
10th Apr 2017, 10:28 PM
prg_Mohamad
prg_Mohamad - avatar