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
valueMoneyThe monetary value whose magnitude is taken.
Returns
Exceptions
- InvalidOperationException
valueis 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
valueMoneyThe monetary value to test.
Returns
IsPositive(Money)
Returns a value indicating whether the specified amount is strictly greater than zero.
public static bool IsPositive(this Money value)
Parameters
valueMoneyThe monetary value to test.
Returns
IsZero(Money)
Returns a value indicating whether the specified amount is zero.
public static bool IsZero(this Money value)
Parameters
valueMoneyThe monetary value to test.
Returns
Sign(Money)
Returns the sign of the specified amount.
public static int Sign(this Money value)
Parameters
valueMoneyThe monetary value to test.
Returns
- int
-1,0, or1.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |