将
int[] nums = { 2, 3, 3, 4, 2, 1, 6, 7, 10 };
var distinct = nums.Distinct();
总是2, 3, 4, 1, 6, 7, 10按顺序返回?
Jar*_*Par 16
Enumerable.Distinct的已定义行为是它将返回无序集合(Documentation).
但是,Linq对象中Distinct的当前实现将保留顺序.但是,对于其他LINQ提供程序并不能保证这一点,并且不应依赖该行为.