开发者

how can i sort array via linq?

开发者 https://www.devze.com 2023-01-04 11:25 出处:网络
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++)

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

精彩评论

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