18 return _name;
19 }
20
21 set 22 { 23 _name = value; 24 } 25 }
26}
27
13 // Same as auto-property.
14 public string Name
15 {
16 get 17 { 18 return _name; 19 } 20
21 set
22 {
Getters and setters with a single statement in their bodies can be simplified using the arrow operator (=>
). This eliminates the need for braces, thereby reducing the indentation and lines used.
public int Age
{
get
{
return _age;
}
set
{
_age = value;
}
}
public int Age
{
get => _age;
set => _age = value;
}