Reputation: 403
I am trying to separate a group of values into bins for a histogram chart. There will be 10 bins in my histogram. To sort and count the number of cases in each bin, I am using an array. The error I am getting is The operand of an increment or decrement operator must be a variable, property or indexer
. idx will give me the bin number that needs to be incremented. I am just unsure of the proper way to increment it. Thank you for the suggestions and comments.
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?
}
}
Upvotes: 1
Views: 8661
Reputation: 3603
You're trying to increment a string which makes no sense. Make your array an array of int instead
Upvotes: 1
Reputation: 744
What you can do is:
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;
}
}
Upvotes: 2
Reputation: 62248
This is a simple: the type returned by your expression binct[idx]
does not support numerical
operation like ++
, +
-
...
To avoid this there are at last a couple of ways:
Upvotes: 3