class Point
{
private int m_PointX;
private int m_PointY;
public Point(int x, int y)
{
m_PointX = x;
m_PointY = y;
}
public
Here is an example for #2
public static Point operator+(int value, Point point2)
{
// logic here.
}
You will have to do the other way with the parameters if you want P2 + 2
to work.
See http://msdn.microsoft.com/en-us/library/8edha89s.aspx for more information.
Both of the previous answers talk about your questions, so I'm not going to intrude on those, but here is an example of using 2+P:
public static Point operator+(int yourInt, Point point)
{
Point P = new Point();
P.X = point.X + yourInt;
P.Y = point.Y + yourInt;
return P;
}
To answer your questions:
null
s as well.int