【发布时间】:2015-09-25 15:23:36
【问题描述】:
我有一个自定义对象的集合如下:
public struct Record {
public string Caller { get; set; }
public DateTime Started { get; set; }
public string Dialed { get; set; }
public decimal Duration { get; set; }
public decimal Cost { get; set; }
public string Location { get; set; }
public Switch Switch { get; set; }
}
public static List<Record> Records { get; set; }
使用 LINQ,如何使用存储在 Record.Started 中的值按升序对 Records 进行排序?
【问题讨论】:
-
var sortedRecords = Records.OrderBy(r => r.Started) -
我只是想知道如何简单地搜索“LINQ 升序”并没有显示很多答案。我刚刚搜索了一下,第一个结果是在 Stackoverflow 上并回答了这个问题。
-
这是关于 SO @Jashaszun 的一半问题
-
混乱是我能找到的所有信息表明它返回一个字符串列表,而不是对象——所以我的印象是
r => r.Started只会返回一个Started的列表而不是Record--- 例如这个 >> stackoverflow.com/questions/18545988/… -
@austinwernli 这是一种可悲的状况......