Skip to main content

Convert to Point

  • 2 minutes to read

Consolidates selected numeric parameters into a Point object.

Convert to Point is a cascading refactoring. That is, the refactoring affects all method calls and method declarations in interfaces, base and descendant classes. For instance, if you apply the refactoring to the method declaration within an interface, it also changes the appropriate method declarations in all implementors and all calls to these methods.

Note

The refactoring is available only if the project includes a reference to the System.Drawing namespace.

#Availability

Available from the context menus or via shortcuts:

  • when the edit cursor or caret is on the method name within the method declaration or reference, provided that the method has only two numeric parameters.
  • when two numeric parameters are selected within a method declaration or call.

Note

The refactoring is available for method declarations in interfaces, base and descendant classes, as well as for the declaration in the current class.

#Example

private void TestMethod()
{
    SetRectCoordinates(200, 150);
}
private void SetRectCoordinates(int x, int y)
{
    MyRectangle.X = y;
    MyRectangle.Y = x;
}
Private Sub TestMethod()
    SetRectCoordinates(200, 150)
End Sub
Private Sub SetRectCoordinates(ByVal x As Integer, ByVal y As Integer)
    MyRectangle.X = x
    MyRectangle.Y = y
End Sub

Result:

private void TestMethod()
{
    SetRectCoordinates(new Point(200, 150));
}
private void SetRectCoordinates(Point point)
{
    MyRectangle.X = point.Y;
    MyRectangle.Y = point.X;
}
Private Sub TestMethod()
    SetRectCoordinates(New Point(200, 150))
End Sub
Private Sub SetRectCoordinates(ByVal lPoint As Point)
    MyRectangle.X = lPoint.X
    MyRectangle.Y = lPoint.Y
End Sub

#Screenshot

CSharpConvertToPoint