I always see properties using a private variable to hold the value like this.
private int _myValue;
public int MyValue { get { return _myValue; } set { _myValue = value; } }
Why can’t I just skip the private variable and do this…
public int MyValue { get { return MyValue; } set { MyValue = value; } }
*Note: I didn’t want to use auto properties because I was hoping to be able to do something like this.
public int MyValue { get { return MyValue.Tolower().Trim(); } set { MyValue = value; } }
Because the infinite loop would eventually cause a StackOverflowException to be thrown.