find the midpoint between two points in csharp

To find the midpoint between two points in C#, you can use the following code:

main.cs
public static Point GetMidpoint(Point point1, Point point2)
{
    int x = (point1.X + point2.X) / 2;
    int y = (point1.Y + point2.Y) / 2;
    return new Point(x, y);
}
170 chars
7 lines

In this code, the GetMidpoint method takes two Point objects as arguments and returns a new Point object that represents the midpoint between the two points.

The X and Y coordinates of the midpoint are calculated by taking the average of the corresponding coordinates of the two input points. These coordinates are then used to create a new Point object that represents the midpoint.

gistlibby LogSnag