我收到错误
错误CS7036没有给出符合所需形式参数的参数' b2' ' Form1.checkInfo(PointF,PointF,PointF,PointF,ref PointF)' WindowsFormsApplication1
当我尝试将参数传递给方法时。这是我的语法,对我来说,它看起来像b2
被声明,被分配和被传递,但是我无法发现我需要改变什么以使错误消失!
private void button1_Click(object sender, EventArgs e)
{
Point[] points = new Point[] { new Point { X = -100, Y = 0 }, new Point { X = 0, Y = 0 } };
PointF returnedPoint = new PointF();
for (int i = 0; i < points.Count(); i++)
{
float X1value = points[i].X;
float X2value = points[i-1].X;
float Y1value = points[i].Y;
float Y2value = points[i-1].Y;
checkInfo(new PointF(X1value, Y1value), new PointF(X2value, Y2value), ref returnedPoint);
}
}
bool checkInfo(PointF a1, PointF a2, PointF b1, PointF b2, ref PointF returnedPoint)
{
//Do stuff here
}
答案 0 :(得分:1)
错误CS7036没有给出对应的参数 'Form1.checkInfo需要形式参数'b2'(PointF,PointF, PointF,PointF,ref PointF)'WindowsFormsApplication1
您的方法checkInfo(PointF a1, PointF a2, PointF b1, PointF b2, ref PointF returnedPoint)
有5个参数,但只用3个参数称它为checkInfo(new PointF(X1value, Y1value), new PointF(X2value, Y2value), ref returnedPoint)
。错误消息抱怨缺少参数。
请参阅下面的评论:
private void button1_Click(object sender, EventArgs e)
{
Point[] points = new Point[] { new Point { X = -100, Y = 0 }, new Point { X = 0, Y = 0 } };
PointF returnedPoint = new PointF();
for (int i = 0; i < points.Count(); i++)
{
float X1value = points[i].X;
float X2value = points[i-1].X;
float Y1value = points[i].Y;
float Y2value = points[i-1].Y;
// Error located here: Only 3 parameters passed - You need to pass 2 more instances of 'PointF'
checkInfo(new PointF(X1value, Y1value), new PointF(X2value, Y2value), ref returnedPoint);
}
}
// Takes 5 parameters
bool checkInfo(PointF a1, PointF a2, PointF b1, PointF b2, ref PointF returnedPoint)
{
//Do stuff here
}