问题
I am using two lists
List<int> a = {1,2,3};
List<int> b = {3};
and using Except to compare and filter them.
var diff = a.Except(b).ToList();
this returns values as
1
2
I need to return a bool value along with that ie. the return values should be as
1 true
2 true
the return type is a List<modelClass>
that has int id, bool isTrue
properties
Can you help me in doing this ?
回答1:
Can't you just do this:
var diff = a.Except(b)
.Select(s=>new modelClass(){id = s, isTrue = true})
.ToList();
来源:https://stackoverflow.com/questions/26250875/add-a-static-value-in-list-when-using-except