Check List for duplications with optional words to exclude

后端 未结 4 1374
無奈伤痛
無奈伤痛 2021-01-20 03:31

I have a method as below. Method return either false/true either when list contains duplicates or not. I would like to extend my method to say for instance (optional) that i

4条回答
  •  野性不改
    2021-01-20 04:18

    You can use Except(). From MSDN:

    Produces the set difference of two sequences by using the default equality comparer to compare values.

    return list.Except(listToExclude).GroupBy(n => n).Any(c => c.Count() > 1);
    

提交回复
热议问题