my code is :
IEnumerable<string> checkboxes
checkboxes contains data :
<"4,12/16/2014 00:00:00">
<"8,11/16/2014 00:00:00">
<"6,10/16/2014 00:00:00">
4,8,6 are FileId
i need to get the fileId of oldDate from checkboxes list
Home / DeveloperSection / Forums / IEnumerable<string> checkboxes get old date
my code is :
IEnumerable<string> checkboxes
checkboxes contains data :
<"4,12/16/2014 00:00:00">
<"8,11/16/2014 00:00:00">
<"6,10/16/2014 00:00:00">
4,8,6 are FileId
i need to get the fileId of oldDate from checkboxes list
David Miller
27-May-2015var allIds = checkboxes.Select(x=>int.Parse(x.Split(new []{','})[0]));
if you want the oldest
int.Parse((checkboxes.OrderBy(x => DateTime.Parse(x.Split(new[] {','})[1])).First()).Split(new[] {','})[0]);
both cases will fail if checkboxes is empty. Please validate first and check the parsing of the date, you may have to pass a proper formatter