Table of Contents

MoneyOfTCurrencyExtensions Class

Definition

Namespace
Bodu.Financial.Extensions
Assembly
Bodu.Financial.dll
Package
Bodu.Financial 1.0.0
Source
MoneyOfTCurrencyExtensions.Abs.cs

Provides sign, magnitude, and comparison convenience members for the strongly-typed Money<TCurrency> type, keeping those derived helpers off the core value type while preserving familiar property-style access.

public static class MoneyOfTCurrencyExtensions
Inheritance
MoneyOfTCurrencyExtensions
Inherited Members

Remarks

Each instance member is a thin projection over Amount and the public arithmetic surface, carrying no state of its own; the Min, Max, and Clamp helpers are static because they compare two or more operands. Splitting them into this extension surface keeps Money<TCurrency> focused on construction, arithmetic, equality, and formatting.

When compiled with a tool-chain that supports C# 14 extension members the instance helpers are exposed as extension properties (for example money.IsZero); otherwise they compile as classic extension methods (for example money.IsZero()).

Methods

Abs<TCurrency>(Money<TCurrency>)

Returns the absolute value of the specified instance.

public static Money<TCurrency> Abs<TCurrency>(this Money<TCurrency> value) where TCurrency : ICurrency

Parameters

value Money<TCurrency>

The monetary value whose magnitude is taken.

Returns

Money<TCurrency>

A Money<TCurrency> whose amount is |Amount|.

Type Parameters

TCurrency

The currency tag identifying the monetary type.

Clamp<TCurrency>(Money<TCurrency>, Money<TCurrency>, Money<TCurrency>)

Clamps value to the inclusive range [min, max].

public static Money<TCurrency> Clamp<TCurrency>(Money<TCurrency> value, Money<TCurrency> min, Money<TCurrency> max) where TCurrency : ICurrency

Parameters

value Money<TCurrency>

The value to clamp.

min Money<TCurrency>

The lower bound (inclusive).

max Money<TCurrency>

The upper bound (inclusive).

Returns

Money<TCurrency>

value when it lies within the range, otherwise the nearer bound.

Type Parameters

TCurrency

The currency tag identifying the monetary type.

Exceptions

ArgumentException

min is greater than max.

IsNegative<TCurrency>(Money<TCurrency>)

Returns a value indicating whether the specified instance is strictly less than zero.

public static bool IsNegative<TCurrency>(this Money<TCurrency> value) where TCurrency : ICurrency

Parameters

value Money<TCurrency>

The monetary value to test.

Returns

bool

true when Amount is negative; false when it is zero or positive.

Type Parameters

TCurrency

The currency tag identifying the monetary type.

IsPositive<TCurrency>(Money<TCurrency>)

Returns a value indicating whether the specified instance is strictly greater than zero.

public static bool IsPositive<TCurrency>(this Money<TCurrency> value) where TCurrency : ICurrency

Parameters

value Money<TCurrency>

The monetary value to test.

Returns

bool

true when Amount is positive; false when it is zero or negative.

Type Parameters

TCurrency

The currency tag identifying the monetary type.

IsZero<TCurrency>(Money<TCurrency>)

Returns a value indicating whether the specified instance represents zero.

public static bool IsZero<TCurrency>(this Money<TCurrency> value) where TCurrency : ICurrency

Parameters

value Money<TCurrency>

The monetary value to test.

Returns

bool

true when Amount is zero; otherwise false.

Type Parameters

TCurrency

The currency tag identifying the monetary type.

Max<TCurrency>(Money<TCurrency>, Money<TCurrency>)

Returns the larger of two monetary values in the same currency.

public static Money<TCurrency> Max<TCurrency>(Money<TCurrency> left, Money<TCurrency> right) where TCurrency : ICurrency

Parameters

left Money<TCurrency>

The first value.

right Money<TCurrency>

The second value.

Returns

Money<TCurrency>

The greater of left and right.

Type Parameters

TCurrency

The currency tag identifying the monetary type.

Min<TCurrency>(Money<TCurrency>, Money<TCurrency>)

Returns the smaller of two monetary values in the same currency.

public static Money<TCurrency> Min<TCurrency>(Money<TCurrency> left, Money<TCurrency> right) where TCurrency : ICurrency

Parameters

left Money<TCurrency>

The first value.

right Money<TCurrency>

The second value.

Returns

Money<TCurrency>

The lesser of left and right.

Type Parameters

TCurrency

The currency tag identifying the monetary type.

Sign<TCurrency>(Money<TCurrency>)

Returns the sign of the specified instance.

public static int Sign<TCurrency>(this Money<TCurrency> value) where TCurrency : ICurrency

Parameters

value Money<TCurrency>

The monetary value to test.

Returns

int

-1 when the amount is negative, 0 when the amount is zero, and 1 when the amount is positive.

Type Parameters

TCurrency

The currency tag identifying the monetary type.

Applies to

ProductVersions
.NET8, 10