I am changing some public field to private by providing corresponding public property.
for example:
public string Name;
is change to
private string _name;
public string Name
{
get{ return _name;}
set{ _name = value;}
}
However, what about the [XmlAttribute] attribute on the original public field?
i.e. does
[XmlAttribute]
public string Name;
becomes:
[XmlAttribute]
private string _name;
public string Name
{
get{ return _name;}
set{ _name = value;}
}
or
private string _name;
[XmlAttribute]
public string Name
{
get{ return _name;}
set{ _name = value;}
}
second solution.
By the way, you don’t need anymore (.net 3.0 and +) a private field, if you don’t do anything special in getter or setter.
You can use auto-implemented properties.