居然说我参数无效。。。慌了,请问这是怎么回事啊?
居然说我参数无效。。。慌了,请问这是怎么回事啊?
这句语句是放在一个循环里面的,源代码是:
for (int i = 0; i < gen; i++)
{
g.DrawLine(myPen, 3, 103, 6, 106);
}
搞笑的是,同样是画线,第一次循环i=0时运行正常,第二次循环i=1时总报错说参数无效。。。明明参数是常数。。。想不通
其它代码我想应该没什么问题的。。。贴一下
for (int i = 0; i < gen_GA-1; i++)
{
//绘制进化曲线
Pen myPen = new Pen(Color.Blue);
int x1, x2, y1, y2;
x1 = Convert.ToInt32(i * pictureBox3.Width / gen_GA);
y1 = pictureBox3.Height - Convert.ToInt32(history_best_fit_GA[i] * pictureBox3.Height / first_fit_GA / 2);
x2 = Convert.ToInt32((i+1) * pictureBox3.Width / gen_GA);
y2 = pictureBox3.Height - Convert.ToInt32(history_best_fit_GA[i+1] * pictureBox3.Height / first_fit_GA / 2);
g.DrawLine(myPen, x1, y1, x2, y2); //这句执行第二次时,即i=1时,x1=3,x2=6,y1=103,y2=106,于是我用常数代入,一样报参数无效的错
myPen = new Pen(Color.Red);
y1 = pictureBox3.Height - Convert.ToInt32(history_avg_fit_GA[i] * pictureBox3.Height / first_fit_GA / 2);
y2 = pictureBox3.Height - Convert.ToInt32(history_avg_fit_GA[i+1] * pictureBox3.Height / first_fit_GA / 2);
g.DrawLine(myPen, x1, y1, x2, y2);
//释放绘图资源
myPen.Dispose();
g.Dispose();
}
[此贴子已经被作者于2007-11-6 9:32:24编辑过]