Skip to main content

Redundant private setter

In This Article

CodeRush Classic shows the Redundant private setter code issue if a property with a backing store contains a private setter.

#Fix

Remove the private setter.

#Purpose

Highlights private set accessors, which can be removed to improve code readability.

#Example

private string _MyProperty;
public string MyProperty
{
    get 
    { 
        return _MyProperty; 
    }private set
    {
        _MyProperty = value;
    }
}

Fix:

private string _MyProperty;
public string MyProperty
{
    get 
    { 
        return _MyProperty; 
    }
}