本文介绍了System.Drawing.Point运算符错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码
position.Location = (e.Location + pic1.Location) - bild_posi.Location;
错误类似:
the operator "+" isnt compatible with "System.Drawing.Point + System.Drawing.Point"
我该如何解决?
推荐答案
这取决于您要如何将点加在一起
It Depends on how you want to add points together
您可以编写一个名为AddPoints的方法和一个名为SubtractPoints的方法,例如
You could write a method called AddPoints and one called SubtractPoints such as
private Point AddPoints(Point A, Point B)
{
return new Point(A.X + B.X, A.Y + B.Y);
}
private Point SubtractPoints(Point A, Point B)
{
return new Point(A.X - B.X, A.Y - B.Y);
}
然后像使用它
position.Location = SubtractPoints(AddPoints(e.Location,pic1.Location),bild_posi.Location);
这篇关于System.Drawing.Point运算符错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!