C#

C#

Made by DeepSource

Getters and setters with a single statement in their bodies can be simplified CS-R1095

Anti-pattern
Major
Autofix

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.

Bad Practice

public int Age
{
    get
    {
        return _age;
    }

    set
    {
        _age = value;
    }
}

Recommended

public int Age
{
    get => _age;
    set => _age = value;
}

Reference