With Unity5 (it’s hard to know exactly which version of C # / Mono / .Net is used), we perform the following properties:
private int _distance; public int Distance { private set { _distance = value; controls.Blahblah(_distance); } get { Debug.Log("hah!); return _distance; } }
But consider new “automatic properties” in C # that seem similar to
public int Distance {get; set;}
but i don't know how to "do something" in getter / setter?
Or, in other words, is there a way to automatically generate a backup variable (as well as the convenience of keeping it private) when it manually creates a property?
Repeat, since this has been marked as a duplicate, how can I "do things" in the automatic identifier Property during getter / setter ...
... or vice versa...
how to hide, get rid of or automatically provide support if you write your own "manual" properties?
Note that, of course, you or another programmer may accidentally touch the _underscore support variable: is there any way to avoid this.
Fatie source share