What I want to achieve is to make sure that my property is always 0 or greater. The type doesn't matter.
Lets say:
var x = 3;
var y = 5;
And after x -= y
x is supposed to be 0.
Currently using this way and was wondering of there is a way without member variables:
public int Coins
{
get { return Math.Max(0, _coins); }
set { _coins = value; }
}
Couldn't either figure out a way with uint.
All suggestions appreciated.
uint x = 3;
uint y = 5;
Expected x beeing 0 after x -= y
but received unit max.