How to compare 2 List objects to get the missing value from the List

前端 未结 5 745
走了就别回头了
走了就别回头了 2021-01-27 02:23

How do I use the \"NOT IN\" to get the missing data, to be added to \"foo\" List.

var accessories = new List(); 
var foo = new List()         


        
5条回答
  •  半阙折子戏
    2021-01-27 02:58

    Use List.Except:

    foo.AddRange(accessories.Except(foo));
    

    From MSDN:

    Except Produces the set difference of two sequences.

提交回复
热议问题