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

Collapse Getter (C#, C++)

Collapses simple getter code onto a single line.

Purpose

This refactoring is great for making your code more compact. With a single keystroke, you can convert a single-statement getter declaration to a single-line form.

Availability

Available from the context menus or via shortcuts:

  • when the caret is within a getter declaration. The getter should consist of a single statement.

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

rsCollapseGetter

See Also