Convert to Size
- 2 minutes to read
In This Article
Consolidates the width and height numeric parameters into a Size object.
Convert to Size 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.
#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 the width and height numeric parameters .
- when the width and height 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 SetRectSize│(int width, int height)
{
MyRectangle.Width = width;
MyRectangle.Height = height;
}
private void TestMethod()
{
SetRectSize(200, 150);
}
Private Sub SetRectSize│(ByVal width As Integer, ByVal height As Integer)
MyRectangle.Width = width
MyRectangle.Height = height
End Sub
Private Sub TestMethod()
SetRectSize(200, 150)
End Sub
Result:
private void SetRectSize(Size size)
{
MyRectangle.Width = size.Width;
MyRectangle.Height = size.Height;
}
private void TestMethod()
{
SetRectSize(new Size(200, 150));
}
Private Sub SetRectSize(ByVal size As Size)
MyRectangle.Width = size.Width
MyRectangle.Height = size.Height
End Sub
Private Sub TestMethod()
SetRectSize(New Size(200, 150))
End Sub