M
Mark
Generally it is recommended to have private variables and allow them
to be accessed through public properties. However, in the class
itself, when i want to modify or read that variable, should i go
through the property or just directly access the variable? What is the
microsoft way?
private _firtName;
public string FirstName;
{
get{return _firstName;}
set{_firstName = value;}
}
public void DoSomething()
{
_firstName = _firstName +"__asdfasd__" + _firstName;
}
// OR
public void DoSomething()
{
FirstName= FirstName+ "__asdfasd__" + FirstName;
}
What is the recommended way?
Thanks
Mark
to be accessed through public properties. However, in the class
itself, when i want to modify or read that variable, should i go
through the property or just directly access the variable? What is the
microsoft way?
private _firtName;
public string FirstName;
{
get{return _firstName;}
set{_firstName = value;}
}
public void DoSomething()
{
_firstName = _firstName +"__asdfasd__" + _firstName;
}
// OR
public void DoSomething()
{
FirstName= FirstName+ "__asdfasd__" + FirstName;
}
What is the recommended way?
Thanks
Mark