开发者

how can i sort array via linq?

if i trying to sort my columns return 0 valu. But i need max value descinding value but how?

 for (int j = 0; j < dTable.Columns.Count; j++)
                for (int i = 0; i < dTable.Rows.Count; i++)
                {
                    mycounte开发者_StackOverflow中文版r[i] = dTable.Rows[i][j].ToString().Length;
                }
            mycounter = mycounter.OrderBy(i => i).ToArray();

            mycounter.Reverse();
            MessageBox.Show(mycounter[0].ToString());


I assume you want to sort in descending order. Just change OrderBy to OrderByDescending.

If you only need the maximum value, use the Max extension method:

mycounter.Max()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜