Home > DeveloperSection > Forums > IEnumerable<string> checkboxes get old date
Allen Scott

Total Post:46

Posted on    May-27-2015 8:00 AM

 .NET ASP.Net  ASP.NET MVC  ListBox 

 1 Reply(s)
 946  View(s)
Rate this:

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

Total Post:30

Posted on    May-27-2015 8:09 AM

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

Don't want to miss updates? Please click the below button!

Follow MindStick