Split Multi-variable Declaration

Splits a single-line multi-variable declarations into multiple lines, with a separate variable declaration on each line. This refactoring is the opposite of Create Multi-variable Declaration.

Availability

Available from the context menu or via shortcuts:

  • when the cursor is on a type identifier within a multi-variable declaration.

Example

private string TestMethod()
{string a = "Hello", b = "World", c = "!";
    return String.Format("{0} {1} {2}", a, b, c);
}
Private Function TestMethod() As StringDim a As String = "Hello", b As String = "World", c As String = "!"
    Return String.Format("{0} {1}{2}", a, b, c)
End Function

Result:

private string TestMethod()
{string a = "Hello";
    string b = "World";
    string c = "!";
    return String.Format("{0} {1} {2}", a, b, c);
}
Private Function TestMethod() As StringDim a As String = "Hello"
    Dim b As String = "World"
    Dim c As String = "!"
    Return String.Format("{0} {1} {2}", a, b, c)
End Function

Screenshot

rsSplitMultiVariableDeclarationCSharp

See Also