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

Last updated:5/27/2015 8:09:05 AM

1 Answers

David Miller
David Miller

var 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