I want to remove the one set of item in resultant list, if both Name\Type
pair is same in both list. I saw Union
, but it's doesn't works. it's give all 4 items.
var data1 = new List<Data>
{
new Data{Name = "N1", Type = "T1"},
new Data{Name = "N2", Type = "T2"},
};
var data2 = new List<Data>
{
new Data{Name = "N1", Type = "T1"},
new Data{Name = "N3", Type = "T3"},
};
var X = data1.Union(data2).Distinct().ToList();
The result should only contains 3 items,
new Data{Name = "N1", Type = "T1"},
new Data{Name = "N2", Type = "T2"},
new Data{Name = "N3", Type = "T3"},