The requested page is not available for the requested platform. You are viewing the content for Default platform.

Convert to Function

Converts a method that returns void, into a function that returns a value of the appropriate type. Selects the reference to the returned value type, and drops a marker onto the initial return keyword.

Availability

From the context menus or via shortcuts:

  • when the edit cursor or caret is on the return keyword, provided that the method returns void.

Notes

This code provider is the opposite of Convert to Procedure.

Example

public void TestMethod()
{return 10;
}
Public Sub TestMethod()Return 10
End Sub

Result:

public int TestMethod()
{
    return 10;
}
Public Function TestMethod() As Integer
    Return 10
End Function