gpt4 book ai didi

c# - 递增数组中的值

转载 作者:太空宇宙 更新时间:2023-11-03 19:12:39 28 4
gpt4 key购买 nike

我正在尝试将一组值分成直方图的 bin。我的直方图中将有 10 个 bin。为了对每个 bin 中的案例数进行排序和计数,我使用了一个数组。我收到的错误是 递增或递减运算符的操作数必须是变量、属性或索引器。 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?
}

}

最佳答案

这很简单:你的表达式binct[idx]返回的类型不支持数值++, + -...

操作

为了避免这种情况,最后有两种方法:

  • Operator overloading
  • 对其他类型执行相同的操作,然后将结果映射到您想要的类型。

关于c# - 递增数组中的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19503639/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com