Most efficient way to compare two lists and delete the same

前端 未结 5 1397
执笔经年
执笔经年 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:13

    Use EnumerableExcept function storing in System.Linq namespace

    finalList = words.Except(badWords).ToList();
    

    Most efficient way to save your time and also the fastest way to do it, because Except implementation uses Set, which is fast

提交回复
热议问题