Method TryIncrementToMax
TryIncrementToMax(ref int, int)
Attempts to increment the specified value up to a maximum value.
Declaration
public static bool TryIncrementToMax(ref int location, int maxValue)
Parameters
Type | Name | Description |
---|---|---|
int | location | The location to be incremented. |
int | maxValue | The maximum value to which the location can be incremented. |
Returns
Type | Description |
---|---|
bool | true if the value was successfully incremented; otherwise, false if the current value is already at or above the maximum value. |
TryIncrementToMax(ref int, int, out int)
Attempts to increment the specified value up to a maximum value.
Declaration
public static bool TryIncrementToMax(ref int location, int maxValue, out int newValue)
Parameters
Type | Name | Description |
---|---|---|
int | location | The location to be incremented. |
int | maxValue | The maximum value to which the location can be incremented. |
int | newValue | When this method returns, contains the new value if the increment was successful, or the current value if the maximum was reached. |
Returns
Type | Description |
---|---|
bool | true if the value was successfully incremented; otherwise, false if the current value is already at or above the maximum value. |