MoneyAllocate(IListDecimal) Method
Allocates the money value proportionately according to the list of values supplied
using the
Money object's current rounding strategy.
Namespace: InnerDrive.FinancialAssembly: InnerDrive.Financial (in InnerDrive.Financial.dll) Version: 5.2.9017.0
public Money[] Allocate(
IList<decimal> proportion
)
- proportion IListDecimal
- An array of values representing the proportions of the
allocation desired.
MoneyAn array of
Money objects
Allocation uses a two-pass algorithm that first distributes the money strictly
proportionately, then allocates extra fractional units starting with the first
element in the list until it runs out of extras.
To allocate money into portions of 1/2, 1/3, and 1/6:
Money money = new Money(1000);
decimal[] alloc = {3M, 2M, 1M}
Money[] results = money.Allocate(alloc);
results now contains three
Money objects with values of $500.01,
$333.33, and $166.66 respectively. To get the result you probably expected, do this:
Money money = new Money(1000);
decimal[] alloc = {1M, 2M, 3M}
Money[] results = money.Allocate(alloc);
results now contains three
Money objects with values of $166.67,
$333.33, and $500.00 respectively.