- Home /
Question by
robinking · Jun 29, 2011 at 09:28 PM ·
c#properties
Why use properties when get{} and set{} do nothing special?
I understand the principles of encapsulation, but why bother with properties like this?
private float _myFloat;
public float MyFloat {
get { return _myFloat; }
set { _myFloat = value; }
}
Doesn't that give clients exactly the same access to the field as making the field public? I do understand that you can do different things with fields, but in the above case what's the point if you're not doing something different than a public field would achieve, other than adhering to best practice?
Comment
Best Answer
Answer by Marnix · Jun 29, 2011 at 09:34 PM
I would like to refer to stackOverflow for this one:
As you can see, there is enough said about it.
Aha. So there is :) Thank you very much. I shall subscribe to SO henceforth...
Your answer