【发布时间】:2013-10-30 11:36:07
【问题描述】:
我正在尝试将一组值分成直方图的箱。我的直方图中将有 10 个 bin。为了对每个箱子中的案例数量进行排序和计算,我使用了一个数组。我得到的错误是The operand of an increment or decrement operator must be a variable, property or indexer。 idx 会给我需要增加的 bin 编号。我只是不确定增加它的正确方法。感谢您的建议和cmets。
int binsize = Convert.ToInt32(xrLabel101.Text) / 10;//Max divided by 10 to get the size of each bin
this.xrChart4.Series[0].Points.Clear();
int binCount = 10;
for (int i = 0; i < binCount; i++)
{
int m = Convert.ToInt32(xrLabel104.Text);//This is the number of loops needed
string[] binct = new string[10];
for (int k = 0; k < m; k++)
{
int idx = Convert.ToInt32(currentcolumnvalue) / binsize;
binct[idx]++;//I know this is wrong. Suggestions?
}
}
【问题讨论】:
-
binct的数据类型是什么?
-
我创建了数组来计算 10 个箱子中每个箱子的病例数。它可以只是一个整数。
-
查看 Tigran 的回答。您正在访问上面代码中索引“idx”处的对象,这是一个字符串数组。您不能增加字符串数组。我假设您也尝试在该 for 循环中使用 k 做某事?
-
k是要排序的事例数。我只是用它来循环适当的次数。