Collapse Getter (C#, C++)
In This Article
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
See Also