我有一个类,长这样:
class Record
{
public string host { get; set; }
public string type { get; set; }
public string name { get; set; }
public string RunAsUser { get; set; }
public string Status { get; set; }
public string StartMode { get; set; }
}
这是一个类的列表:
List<Record> Records = new List<Record>();
这个列表包含许多条目。如何按照 Record.host
的字母顺序对此列表进行排序?
是否有内置函数可以使用,还是我需要编写自己的排序函数?如果需要自己编写,是否可以给我一些伪代码指导方向?
List<Record> acending = descending.OrderBy(x => x.host).ThenBy(x => x.name).ToList();
- JohnB