我有一个机器工作的日期列表,但它不包括机器停机的日期。我需要创建工作天数和未工作天数的列表。我不确定执行此操作的最佳方法。我已经开始递增一个范围的所有天数,并通过每次迭代整个列表来检查日期是否在列表中。我正在寻找一种更有效的方法来查找日期。
class machineday
{
datetime WorkingDay;
}
class machinedaycollection : List<machineday>
{
public List<TimeCatEvent> GetAllByCat(string cat)
{
_CategoryCode = cat;
List<machineday> li = this.FindAll(delegate(machinedaydummy) { return true; });
li.Sort(sortDate);
return li;
}
int sortDate(machinedayevent1, machinedayevent2)
{
int returnValue = -1;
if (event2.date < event1.date)
{
returnValue = 0;
}
else if (event2.date == event1.date)
{
//descending
returnValue = event1.date.CompareTo(event2.date);
}
return returnValue;
}
}