Sort string list with dates in C#

前端 未结 6 1593
不知归路
不知归路 2020-12-31 07:00

I have a List with dates.
My list is:

{\"01/01/2013\",\"10/01/2013\",\"20/01/2013\"}

I want to sort the list

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-31 07:58

    Try this:

    List s = new List() { "01/01/2013", "10/01/2013", "20/01/2013" };
    var d = s.OrderByDescending(i => DateTime.ParseExact(i, "dd/MM/yyyy", null));
    

提交回复
热议问题