MemoryStorage.Plus(int,decimal) - YiZhang-Paul/Mock_Up_Calculator GitHub Wiki
Namespace: StorageClassLibrary
Description: Adds arbitrary value to value at specified index.
Parameters | Description |
---|---|
key<int> | index to add to |
value<decimal> | value to add |
Returns | Description |
---|---|
void | this method does not return anything |
Exceptions | Cause |
---|---|
ArgumentOutOfRangeException | key < 0 or key >= Size of storage |
OverflowException | addition results in a value larger than decimal.MaxValue |
Examples:
decimal[] values = { 1, 3, 5, 7 };
var storage = new MemoryStorage(values); //now contains [1, 3, 5, 7]
storage.Plus(0, 9); //now contains [10, 3, 5, 7]
storage.Plus(1, -7); //now contains [10, -4, 5, 7]
storage.Plus(-1, 9); //will throw exception
storage.Plus(2, decimal.MaxValue); //will throw exception