Skip to main content

Inline Constant

Replaces a constant reference with its defined value, removing the constant declaration if there are no other references to it.

#Availability

Available from the context menu or via shortcuts:

  • when the edit cursor or caret is on a constant reference.

#Example

private const int MyConst = 15;
private int TestMethod(int param1)
{
    return param1 * MyConst;
}
Private Const MyConst As Integer = 15
Private Function TestMethod(ByVal param1 As Integer) As Integer
    Return param1 * MyConst
End Function

Result:

private int TestMethod(int param1)
{
    return param1 * 15;
}
Private Function TestMethod(ByVal param1 As Integer) As Integer
    Return param1 * 15
End Function

#Screenshot

rsInlineConstant

See Also