Automatic property
Why it is called automatic property.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Sep 3, 2012, 6:25 AM EDT
public int MyProp { get; set; }
into this:
private int _myInt; // in practice this will be something very obscure
public int MyProp
{
get { return _myInt; }
set { _myInt = value; }
}
The private field is not directly accessible (except by using reflection) and so you always need to access it via the automatic property.
Posted Sep 3, 2012, 7:09 AM EDT