nyc*_*dtd 1 c# sorting list nested-lists
我在c#中有以下结构:
public class Circus {
int Id;
public List<Performers> Performers = new List<Performers>();
}
public class Performer {
int Id;
public List<Talents> Talents = new List<Talents>();
}
public class Talent {
public int Id;
public string Name;
public int skill;
}
Run Code Online (Sandbox Code Playgroud)
我如何按技能订购表演者(Talent.Id == 1)?也就是说,我需要通过它的子列表的属性来命令List.我已经尝试了各种尝试和搜索,但是还没有以这种方式排序列表.预先感谢您的任何帮助.
LINQ解决方案:
var ordered = source.OrderBy(p => p.Talents.First(t => t.Id == 1).Skill).ToList();
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1729 次 |
最近记录: |