【发布时间】:2011-08-14 22:38:53
【问题描述】:
I.E.如果我想从数组中进行选择,结果IEnumerable<object> 对象是否必须按顺序排列?
public class Student { public string FullName, ... }
public class School { public string Name, public Student[] Students, ... }
public void StudentListWork(School thisSchool)
{
IEnumerable<string> StudentNames = thisSchool.Students.Select(student => student.FullName);
// IS StudentNames GUARANTEED TO BE IN THE SAME ORDER AS thisSchool.Students?
}
谢谢!
【问题讨论】:
-
什么是学生?一个列表?排序列表?数组?一本字典? “收藏”是一个广义的术语,它们具有不同的特点。
-
@Mystere:根据第二行,它是一个数组。
-
@Jon Skeet-Doh!错过了……
-
有序集合的 IEnumerable 实现不会竭尽全力以无序序列返回项目。不保证,只是马感。你可以依赖它,它不会被破坏。
标签: c# .net collections