IENUMERABLE<STRING> CHECKBOXES GET OLD DATE

Allen Scott

Total Post:46

Points:324
Posted by  Allen Scott
 967  View(s)
Ratings:
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

  1. David Miller

    Post:30

    Points:210
    Re: IEnumerable<string> checkboxes get old date

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!