c# - Sorting List by DateTime -
i have tried solutions have found , cannot seem make work me.
i have class:
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; }
i make call service:
invokegetreportrequestlistresponse callresponse = invokegetreportrequestlist(callrequest);
and want sort reports
list in callresponse
completeddate
callresponse.reports.sort((x, y) => datetime.compare(x.completeddate, y.completeddate));
this returns error:
cannot convert lambda expression type 'system.collections.generic.icomparer<webfeeds.amazon.api.datatypes.requestedreport>' because not delegate type
sorting can done using linq via following statement.
var result = callresponse.report.orderby( iitem => iitem.completeddate );
Comments
Post a Comment