In Visual Studio 2008 Team System, I just performed code analysis (from the analysis menu) on one of my C # projects. One of the warnings received was the following:
Microsoft.Design: since the "Connection._domain" field is displayed outside of its declaration type, change its accessibility to private and add the property with the same availability as the field at present to provide access to it.
This applies to the following field:
public abstract class Connection
{
protected string _domain;
}
I do not understand the arguments in favor of the proposal. This is what I think he wants me to do:
public abstract class Connection
{
private string _domain;
protected string Domain { get { return _domain; } set { _domain = value; } }
}
Two questions:
- Did I understand correctly what the code offer offers me?
- Why does he want me to do this?