Is there any way to get the + operator to work for the Point object?
Take, for example, this tiny snippet:
this.cm1.Show((MouseEventArgs)e.Location+this.i_rendered.Location);
You see, I try to add two points to eachother. It just does not work (which was expected). I’d love to get this working.
Any ideas?
It’s not going to happen the way you expect. The only overload that the
Pointstructure provides for the+(addition) operator is one that translates the coordinates of thePointby aSize.There’s no way to add two
Pointstructures together, and I’m not even sure what that would mean.Don’t waste too much time figuring it out, either, considering that you cannot write extension methods that overload operators.
Fortunately, in a compiled language, there’s no penalty for splitting up code into multiple lines. So you can re-write your code as follows:
Alternatively, you could use the
Offsetmethod, but I’m not convinced that enhances readability.