Most efficient way to compare two lists and delete the same

前端 未结 5 1399
执笔经年
执笔经年 2021-01-19 16:57

I want to compare two lists and get the valid words into a new list.

var words = new List();
var badWords = new List();

//this i         


        
5条回答
  •  面向向阳花
    2021-01-19 17:02

    If your don't want to create a new List you can remove the bad words from your existing List with RemoveAll()

    words.RemoveAll(badWords.Contains);
    

提交回复
热议问题