我有这段代码:
var groups = netflow.OrderByDescending(x => x).GroupBy(x => x).Select(x => x.Key).ToArray();
var rank = netflow.Select(x => Array.IndexOf(groups, x)+1);
我想用rank变量更新datagridview中出现的所有数据。我已经尝试过这段代码:
int[] rankResult = rank;
for (int ii = 0; ii < rankResult.Length; ii++)
{
string empNumb = dataGridView1[dataGridView1.Columns["empNumb"].Index, ii].Value.ToString();
RC.updateRank(rankResult[ii], empNumb, period, year);
}
答案 0 :(得分:0)
我建议您将代码更改为:
var rankResult = rank.ToList(); // Or int[] rankResult = rank.ToArray<int>();
for (int ii = 0; ii < rankResult.Length; ii++)
{
string empNumb = dataGridView1[dataGridView1.Columns["empNumb"].Index, ii].Value.ToString();
RC.updateRank(rankResult[ii], empNumb, period, year);
}