我正在尝试将一组值分成直方图中的二进制数。我的直方图中会有10个箱子。要对每个bin中的个案数进行排序和计数,我使用的是数组。我得到的错误是The operand of an increment or decrement operator must be a variable, property or indexer
。 idx会给我需要增加的bin号。我只是不确定增加它的正确方法。感谢您的建议和意见。
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?
}
}
答案 0 :(得分:3)
这很简单:表达式binct[idx]
返回的类型不支持数字
像++
,+
-
...
为了避免这种情况,最后有几种方法:
答案 1 :(得分:2)
你能做的是:
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
int[] binct = new int[10];
for (int k = 0; k < m; k++)
{
int idx = Convert.ToInt32(currentcolumnvalue) / binsize;
binct[idx] = binct[idx] + 1;
}
}
答案 2 :(得分:1)
你试图增加一个毫无意义的字符串。使您的数组成为int数组