Skip to main content

Expand Getter (C#, C++)

Expands single-line getter code onto multiple lines.

#Purpose

This refactoring is great if you plan to expand a property’s getter body. With a single keystroke, you can reformat a single-line accessor declaration into a multiple line format. This will make it easier to start modifications.

#Availability

Available from the context menus or via shortcuts:

  • when the caret is within a getter declaration. The getter should have a single-line format.

#Example

private string _MyProperty;
public string MyProperty
{get { return _MyProperty; }
    set { _MyProperty = value; }
}

Result:

private string _MyProperty;
public string MyProperty
{get
    {
        return _MyProperty;
    }
    set { _MyProperty = value; }
}

#Screenshot

rsExpandGetter

See Also