MoneyAllocate(IListDecimal) Method

Allocates the money value proportionately according to the list of values supplied using the Money object's current rounding strategy.

Definition

Namespace: InnerDrive.Financial
Assembly: InnerDrive.Financial (in InnerDrive.Financial.dll) Version: 5.2.9017.0
C#
public Money[] Allocate(
	IList<decimal> proportion
)

Parameters

proportion  IListDecimal
An array of values representing the proportions of the allocation desired.

Return Value

Money
An array of Money objects

Remarks

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.

Example

To allocate money into portions of 1/2, 1/3, and 1/6:
C#
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:
C#
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.

Exceptions

ArgumentExceptionproportion has no values
ArgumentNullExceptionproportion is null
ArgumentOutOfRangeExceptionAny value of proportion less than 0

See Also