Próbowałem znaleźć rozwiązania, które znalazłem i nie mogę sprawić, żeby to działało dla mnie.Sortowanie listy według daty DateTime
Mam klasy:
public class InvokeGetReportRequestListResponse
{
public MarketplaceWebServiceException Error { get; set; }
public bool CallStatus { get; set; }
public List<RequestedReport> Reports { get; set; }
}
public class RequestedReport
{
public String ReportRequestId;
public String ReportType;
public DateTime? StartDate;
public DateTime? EndDate;
public Boolean Scheduled;
public DateTime? SubmittedDate;
public String ReportProcessingStatus;
public String GeneratedReportId;
public DateTime? StartedProcessingDate;
public DateTime? CompletedDate;
}
nawiązywać połączenia z usługą:
InvokeGetReportRequestListResponse callResponse = InvokeGetReportRequestList(callRequest);
a teraz chcę, aby posortować listę w callResponse
Reports
przez CompletedDate
callResponse.Reports.Sort((x, y) => DateTime.Compare(x.CompletedDate, y.CompletedDate));
Thi s zwraca błąd:
Cannot convert lambda expression to type 'System.Collections.Generic.IComparer<WebFeeds.Amazon.API.DataTypes.RequestedReport>' because it is not a delegate type
jaka jest używana wersja platformy .NET? ten kod powinien działać dobrze w .Net 4 i powyżej –
VS2012 docelowego ram 4.0. – Fred