当我尝试从自定义对象列表中删除重复项时,
以下是我失败的尝试:
1-
var blob = await fetch(documentUtils.getDocumentURL()).then(r => r.blob());
2-
model.DatesList = model.DatesList .Distinct().ToList();
3-
List<DateTimeMask> newDates = new List<DateTimeMask>();
foreach (DateTimeMask _date in DatesList)
{
if (!newDates.Contains(_date)) newDates.Add(_date);
}
DatesList = newDates;
我在做什么错了?
感谢您的帮助
编辑:这是对象的外观
model.DatesList = model.DatesList.Select(x=> new DateTimeMask
{
DayOfTheWeek = x.DayOfTheWeek,
DateToString = x.DateToString,
DateTallinn = x.DateTallinn,
}).Distinct().ToList();