注册 登录
编程论坛 C# 论坛

代码显示错误,不知道怎么改,恳请各位大神指教

米粒大小3 发布于 2017-03-06 10:28, 2113 次点击
错误提示:[local]1[/local]
 if (Iteration == 1)
                {
                    double[,] best_flames = new double[population, dim];
                    double[,] best_flame_fitness = new double[1, population];
                    DiYiCi(Moth_pos,ub, lb, dim, population, out best_flames, out best_flame_fitness);
                }
                else
                {

                }
                Best_flame_score = best_flame_fotness[0, 1];
                for (int i = 0; i < dim; i++)
                {
                    Best_flame_pos = best_flames[0, i];
                }
2 回复
#2
米粒大小32017-03-06 10:30
错误就是,上面明面计算出了out best_flames, out best_flame_fitness这俩,然后下面提示(也就是红色字体)上下文不存在,怎么破?
#3
yhlvht2017-03-06 21:37
变量的作用域
那两个数组的定义是在if里面,当出了if的那对大括号以后,就不起作用了。
需要把那两个数组定义在外面
1