У меня есть список объектов DateTimeOffset
, и я хочу вставить новые в список по порядку.
List<DateTimeOffset> TimeList = ...
// determine the order before insert or add the new item
Извините, нужно обновить мой вопрос.
List<customizedClass> ItemList = ...
//customizedClass contains DateTimeOffset object and other strings, int, etc.
ItemList.Sort(); // this won't work until set data comparison with DateTimeOffset
ItemList.OrderBy(); // this won't work until set data comparison with DateTimeOffset
Кроме того, как поставить DateTimeOffset
в качестве параметра .OrderBy()
?
Я также попробовал:
ItemList = from s in ItemList
orderby s.PublishDate descending // .PublishDate is type DateTime
select s;
Тем не менее, он возвращает это сообщение об ошибке,
Не удалось неявно преобразовать тип 'System.Linq.IOrderedEnumerable' в 'System.Collections.Gerneric.List'. Существует явное преобразование (вам не хватает приведения?)