Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# on(对于Distinctmethod)只是表示“未排序”,而不是“以不可预测的顺序”。我想说,Distinct属于上面的过滤类别,就像Where一样。因此,因为OrderBy是一种稳定的排序,那么:seq.OrderBy(=>Ukey)将把元素放入与se_C#_Arrays_Linq_Sorting_Data Structures - Fatal编程技术网

C# on(对于Distinctmethod)只是表示“未排序”,而不是“以不可预测的顺序”。我想说,Distinct属于上面的过滤类别,就像Where一样。因此,因为OrderBy是一种稳定的排序,那么:seq.OrderBy(=>Ukey)将把元素放入与se

C# on(对于Distinctmethod)只是表示“未排序”,而不是“以不可预测的顺序”。我想说,Distinct属于上面的过滤类别,就像Where一样。因此,因为OrderBy是一种稳定的排序,那么:seq.OrderBy(=>Ukey)将把元素放入与se,c#,arrays,linq,sorting,data-structures,C#,Arrays,Linq,Sorting,Data Structures,on(对于Distinctmethod)只是表示“未排序”,而不是“以不可预测的顺序”。我想说,Distinct属于上面的过滤类别,就像Where一样。因此,因为OrderBy是一种稳定的排序,那么:seq.OrderBy(=>Ukey)将把元素放入与seq.GroupBy(=>Ukey)完全相同的顺序。SelectMany(=>Ukey)。是这样吗?@dmg:不,不会的。只需GroupBy后跟SelectMany即可给出按键分组的结果,但不会按键升序排列。。。它将按照密钥最初出现的顺序给出它们


on(对于
Distinct
method)只是表示“未排序”,而不是“以不可预测的顺序”。我想说,
Distinct
属于上面的过滤类别,就像
Where
一样。因此,因为OrderBy是一种稳定的排序,那么:seq.OrderBy(=>Ukey)将把元素放入与seq.GroupBy(=>Ukey)完全相同的顺序。SelectMany(=>Ukey)。是这样吗?@dmg:不,不会的。只需
GroupBy
后跟
SelectMany
即可给出按键分组的结果,但不会按键升序排列。。。它将按照密钥最初出现的顺序给出它们。你是说LINQ to SQL不保留顺序吗?@symbont:在许多SQL操作中,没有定义好的顺序开始。基本上,我只是试图对我能保证的事情做出承诺——比如LINQ到对象。@Paulustricous:在LINQ到对象中,是的。在其他提供程序中,它是特定于实现的。如果我没有弄错的话,
ToDictionary()
只是对顺序不做任何承诺,但实际上会维护输入顺序(直到您从中删除某些内容)。我不是说要依赖这个,但“混乱”似乎不准确。
    private static IEnumerable<TSource> DistinctIterator<TSource>
      (IEnumerable<TSource> source, IEqualityComparer<TSource> comparer)
    {
        Set<TSource> set = new Set<TSource>(comparer);
        foreach (TSource element in source)
            if (set.Add(element)) yield return element;
    }
mysqlresult.OrderBy(e=>e.SomeColumn)