Table of Contents

MoneyExtensions Class

Definition

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

Provides sign, magnitude, and related convenience members for the runtime-tagged Money type, keeping those derived helpers off the core value type while preserving familiar property-style access.

public static class MoneyExtensions
Inheritance
MoneyExtensions
Inherited Members

Remarks

Each member is a thin projection over Amount and the public arithmetic surface, carrying no state of its own. Splitting them into this extension surface keeps Money focused on construction, arithmetic, equality, and formatting.

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

Methods

Abs(Money)

Returns the absolute value of the specified amount.

public static Money Abs(this Money value)

Parameters

value Money

The monetary value whose magnitude is taken.

Returns

Money

A Money with the same ISO code and a non-negative amount.

Exceptions

InvalidOperationException

value is a default-initialised, currency-less Money.

IsNegative(Money)

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

public static bool IsNegative(this Money value)

Parameters

value Money

The monetary value to test.

Returns

bool

true when negative; otherwise false.

IsPositive(Money)

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

public static bool IsPositive(this Money value)

Parameters

value Money

The monetary value to test.

Returns

bool

true when positive; otherwise false.

IsZero(Money)

Returns a value indicating whether the specified amount is zero.

public static bool IsZero(this Money value)

Parameters

value Money

The monetary value to test.

Returns

bool

true when Amount is zero; otherwise false.

Sign(Money)

Returns the sign of the specified amount.

public static int Sign(this Money value)

Parameters

value Money

The monetary value to test.

Returns

int

-1, 0, or 1.

Applies to

ProductVersions
.NET8, 10