Point Structure
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional plane.
Namespace: System.Drawing
Assembly: System.Drawing (in System.Drawing.dll)
The Point type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Point(Int32) | Initializes a new instance of the Point class using coordinates specified by an integer value. |
![]() | Point(Size) | Initializes a new instance of the Point class from a Size. |
![]() | Point(Int32, Int32) | Initializes a new instance of the Point class with the specified coordinates. |
| Name | Description | |
|---|---|---|
![]() ![]() | Add | Adds the specified Size to the specified Point. |
![]() ![]() | Ceiling | Converts the specified PointF to a Point by rounding the values of the PointF to the next higher integer values. |
![]() | Equals | Specifies whether this Point contains the same coordinates as the specified Object. (Overrides ValueType.Equals(Object).) |
![]() | GetHashCode | Returns a hash code for this Point. (Overrides ValueType.GetHashCode().) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | Offset(Point) | Translates this Point by the specified Point. |
![]() | Offset(Int32, Int32) | Translates this Point by the specified amount. |
![]() ![]() | Round | Converts the specified PointF to a Point object by rounding the Point values to the nearest integer. |
![]() ![]() | Subtract | Returns the result of subtracting specified Size from the specified Point. |
![]() | ToString | Converts this Point to a human-readable string. (Overrides ValueType.ToString().) |
![]() ![]() | Truncate | Converts the specified PointF to a Point by truncating the values of the Point. |
| Name | Description | |
|---|---|---|
![]() ![]() | Addition | Translates a Point by a given Size. |
![]() ![]() | Equality | Compares two Point objects. The result specifies whether the values of the X and Y properties of the two Point objects are equal. |
![]() ![]() | Explicit(Point to Size) | Converts the specified Point structure to a Size structure. |
![]() ![]() | Implicit(Point to PointF) | Converts the specified Point structure to a PointF structure. |
![]() ![]() | Inequality | Compares two Point objects. The result specifies whether the values of the X or Y properties of the two Point objects are unequal. |
![]() ![]() | Subtraction | Translates a Point by the negative of a given Size. |
The following code example creates points and sizes using several of the overloaded operators defined for these types. It also demonstrates how to use the SystemPens class.
This example is designed to be used with Windows Forms. Create a form that contains a Button named subtractButton. Paste the code into the form and call the CreatePointsAndSizes method from the form's Paint event-handling method, passing e as PaintEventArgs.
private void CreatePointsAndSizes(PaintEventArgs e) { // Create the starting point. Point startPoint = new Point(subtractButton.Size); // Use the addition operator to get the end point. Point endPoint = startPoint + new Size(140, 150); // Draw a line between the points. e.Graphics.DrawLine(SystemPens.Highlight, startPoint, endPoint); // Convert the starting point to a size and compare it to the // subtractButton size. Size buttonSize = (Size)startPoint; if (buttonSize == subtractButton.Size) // If the sizes are equal, tell the user. { e.Graphics.DrawString("The sizes are equal.", new Font(this.Font, FontStyle.Italic), Brushes.Indigo, 10.0F, 65.0F); } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
