C# How to Prevent Accidentally Editing Backing Store of a Property

时间:2019-04-16 22:13:27

标签: c#

In C#, is there a way to not accidentally edit the backing store instead of the property?

(Assuming they are in the same class)

int num;
int Num { 
  set {
    num = Mathf.Abs(value);
  }
}

num++

Should be editing Num, not num

(Someone's going to say "Just don't forget")

0 个答案:

没有答案