Offset
This method is available in both the Point and PointF classes, and it is mainly used to programmatically move or adjust the coordinates of a certain point. The Offset()
method modifies the current x and y coordinates of a point without returning a new Point object.
To use the Offset()
method, simply call it with two integer values as arguments on a Point
or PointF
object. The first argument will offset the Point's x coordinate, while the second argument will offset the Point's y-coordinate. This method also accepts negative values as arguments.
In the code snippet above, a PointF
object is instantiated along with the x and y coordinates. The Offset()
method is then called with both a negative and positive value. Optionally, the final x and y coordinate values of this point can be checked by printing the X and Y coordinate values of the PointF
object to the console.