Point.Offset Method

Definition

Translates the Point by the specified amount.

Overloads

Offset(Int32, Int32)

Translates this Point by the specified amount.

Offset(Point)

Translates this Point by the specified Point.

Offset(Int32, Int32)

Source:
Point.cs
Source:
Point.cs
Source:
Point.cs

Translates this Point by the specified amount.

C#
public void Offset(int dx, int dy);

Parameters

dx
Int32

The amount to offset the x-coordinate.

dy
Int32

The amount to offset the y-coordinate.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

Offset(Point)

Source:
Point.cs
Source:
Point.cs
Source:
Point.cs

Translates this Point by the specified Point.

C#
public void Offset(System.Drawing.Point p);

Parameters

p
Point

The Point used offset this Point.

Examples

The following example shows how to use the Offset method. To run this example, paste it into a Windows Form. Handle the form's Paint event and call the OffsetPoint method from the Paint event-handling method, passing e as PaintEventArgs.

C#
private void OffsetPoint(PaintEventArgs e)
{
    Point point1 = new Point(10, 10);
    point1.Offset(50, 0);
    Point point2 = new Point(250, 10);
    e.Graphics.DrawLine(Pens.Red, point1, point2);
}

Remarks

This method adjusts the X and Y values of this Point to the sum of the X and Y values of this Point and p.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1