Sorry If I am being noob, I have this doubt, why do we use private variables and set them using properties ?
Why can't we just use properites alone ?
I am talking about situations like this
private string _testVariable;
public string MyProperty
{
get { return _testVariable;}
set {_testVariable = value;}
}
I am thinking of simply using
public string MyProperty { get; set; }
Why redundant private variable? are these two strategies different ? can anyone please throw some light on this.
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…