Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

POINT (Structures)
 
.
Summary
The POINT structure defines the x- and y-coordinates of a point.

C# Signature:

[StructLayout(LayoutKind.Sequential)]
struct POINT  {
    public int x;
    public int y;

    public POINT(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public Point ToPoint() {
        return new Point(x, y);
    }

    public static POINT FromPoint(Point pt) {
        return new POINT(pt.X, pt.Y);
    }

    public override bool Equals(object obj)
    {
        // I wish we could use the "as" operator
        // and check the type compatibility only
        // once here, just like with reference
        // types. Maybe in the v2.0 :)

        if (!(obj is POINT))
        {
            return false;
        }

        POINT point = (POINT)obj;

        if (point.x == this.x)
        {
            return (point.y == this.y);
        }

        return false;
    }

    public override int GetHashCode()
    {
        // this is the Microsoft implementation for the
        // System.Drawing.Point's GetHashCode() method.
        return (this.x ^ this.y);
    }

    public override string ToString() {
        return string.Format("{{X={0}, Y={1}}}", x, y);
    }
}

VB .NET Signature:

<StructLayout(LayoutKind.Sequential)> Structure POINT
    Public x As Integer
    Public y As Integer

    Public Sub New(ByVal x As Integer, ByVal y As Integer)
        Me.x = x
        Me.y = y
    End Sub

    Public Function ToPoint() As System.Drawing.Point
        Return New System.Drawing.Point(x, y)
    End Function

    Public Shared Function FromPoint(ByVal pt As System.Drawing.Point) As POINT
        Return New Point(pt.X, pt.Y)
    End Function

    Public Overrides Function ToString() As String
        Return String.Format("{{X={0}, Y={1}}}", x, y)
    End Function
End Structure

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

Alternative Managed API:

System.Drawing.Point

System.Drawing.PointF

Documentation
POINT on MSDN

Please edit this page!

Do you have...

  • helpful tips?
  • corrections to the existing content?
  • alternate definitions?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing any supporting types needed.

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions