Point.Offset(Double, Double) 方法


将某个点的 X 坐标和 Y 坐标偏移指定的量。Offsets a point's X and Y coordinates by the specified amounts.

 void Offset(double offsetX, double offsetY);
public void Offset (double offsetX, double offsetY);
member this.Offset : double * double -> unit
Public Sub Offset (offsetX As Double, offsetY As Double)



要偏移该点 X 坐标的量。The amount to offset the point's X coordinate.


要偏移该点 Y 坐标的量。The amount to offset the point's Y coordinate.


下面的示例演示如何偏移结构的 XYPointThe following example shows how to offset the X and Y values of a Point structure.

private Point offsetExample()
    Point pointResult = new Point(10, 5);

    // Offset Point X value by 20 and Y value by 30.
    // point1 is now equal to (30,35)
    pointResult.Offset(20, 30);

    return pointResult;


此操作等效于将添加 PointVectorThis operation is equivalent to adding a Point to a Vector.

请注意, Offset 仅当可以直接更改和属性时,调用方法才会起作用 X YNote that calling the Offset method will only have an effect if you can change the X and Y properties directly. 由于 Point 是一个值类型,因此,如果 Point 使用属性或索引器引用对象,则会获得对象的副本,而不是对对象的引用。Because Point is a value type, if you reference a Point object by using a property or indexer, you get a copy of the object, not a reference to the object. 如果尝试对 X Y 属性或索引器引用进行更改,则会出现编译器错误。If you attempt to change X or Y on a property or indexer reference, a compiler error occurs. 同样, Offset 对属性或索引器调用将不会更改基础对象。Similarly, calling Offset on the property or indexer will not change the underlying object. 如果要更改被 Point 引用为属性或索引器的的值,请创建新的 Point ,修改其字段,然后将 Point 返回回属性或索引器。If you want to change the value of a Point that is referenced as a property or indexer, create a new Point, modify its fields, and then assign the Point back to the property or indexer.