C#

C#

Made by DeepSource

Getter and setter should access the same fields CS-W1095

Bug risk
Critical

Accessors such as getter and setter are responsible for fetching and setting a backing field's value. It is always expected that these accessors refer to and operate on the same backing field. However, in this case, each accessor accesses a different field. This is likely a mistake and should be fixed accordingly.

Bad Practice

get
{
    return _foo;
}

set
{
    _bar = value;
}

Recommended

get
{
    return _foo;
}

set
{
    _foo = value;
}

References