C# Counter with max

Date: 2023-08-31
public class CounterWithMax
{
    public int Count;
    public int Max;

    public bool TryIncrease()
    {
        if (!CanIncrease()) return false;
        Count += 1;
        return true;
    }

    public bool CanIncrease() => Count < Max;
    public void Decrease() => Count -= 1;
    public CounterWithMax(int initial, int max)
    {
        Count = initial;
        Max = max;
    }
}
80100cookie-checkC# Counter with max