"DKode" <dk****@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Ok,
kind of a silly question I just want to know what the proper method is,
When I have local Properties, ie:
private bool _someVal;
public bool SomeVal {
get { return _someVal; }
}
When I accessing this property within the class it exists in, should I
use _someVal or always use the Property to retrieve the value?
Not a silly question at all. In fact, it's the subject of much debate.
There are 3 situations to consider:
1. You want the functionality of the property. Obviously, use the property.
2. You explicitly DO NOT want the functionality of the property. Obviously,
do not use the property.
3. Using the property and the field is functionally equivalent. Here you've
got to see into the future to make a determination. If you use the property,
then your code is dependent on the property getter/setter code. If you use
the field, it is not. If someone should change the getter/setter in the
future, what should happen to the piece of code you are writing? I think you
have to take it on a case by case basis.