Struct MonetaryValue
Represents a monetary amount in a specific currency.
Implements
Namespace: Singulink.Globalization
Assembly: Singulink.Globalization.Currency.dll
Syntax
public readonly struct MonetaryValue : IComparable<MonetaryValue>, IEquatable<MonetaryValue>, ISpanFormattable, IFormattable, IAdditionOperators<MonetaryValue, MonetaryValue, MonetaryValue>, IAdditionOperators<MonetaryValue, decimal, MonetaryValue>, IComparisonOperators<MonetaryValue, MonetaryValue, bool>, IEqualityOperators<MonetaryValue, MonetaryValue, bool>, IDecrementOperators<MonetaryValue>, IDivisionOperators<MonetaryValue, decimal, MonetaryValue>, IDivisionOperators<MonetaryValue, MonetaryValue, decimal>, IIncrementOperators<MonetaryValue>, IMultiplyOperators<MonetaryValue, decimal, MonetaryValue>, ISubtractionOperators<MonetaryValue, MonetaryValue, MonetaryValue>, ISubtractionOperators<MonetaryValue, decimal, MonetaryValue>, IUnaryNegationOperators<MonetaryValue, MonetaryValue>, IUnaryPlusOperators<MonetaryValue, MonetaryValue>, ISpanParsable<MonetaryValue>, IParsable<MonetaryValue>
Constructors
| Name | Description |
|---|---|
| MonetaryValue(decimal, Currency) | Initializes a new instance of the MonetaryValue struct with the specified amount and currency. |
| MonetaryValue(decimal, string) | Initializes a new instance of the MonetaryValue struct with the specified amount and currency code from the Default currency registry. |
Properties
| Name | Description |
|---|---|
| Amount | Gets the amount this value represents in its currency. |
| Currency | Gets the currency associated with this value. |
| CurrencyOrDefault | Gets the currency associated with this value or null if this is a default monetary value with no currency associated with it. |
| Default | Gets the default MonetaryValue value, which is not associated with any currency and has a zero amount. |
| IsDefault | Gets a value indicating whether this is a default value. Default values have a |
Methods
| Name | Description |
|---|---|
| CompareTo(MonetaryValue) | Compares this value to the specified value. Values in different currencies are ordered by their currencies first. |
| Create(decimal, Currency) | Creates a new MonetaryValue value with the specified amount and currency. |
| Create(decimal, string) | Creates a new MonetaryValue value with the specified amount and currency code from the Default currency registry. |
| CreateDefaultable(decimal, Currency?) | Creates a new MonetaryValue value with the specified amount and currency. Allows creating default monetary values by passing |
| CreateDefaultable(decimal, string?) | Creates a new MonetaryValue value with the specified amount and currency code from the Default currency registry.
Allows creating default monetary values by passing |
| Equals(MonetaryValue) | Determines whether this value is equal to the specified value. |
| Equals(MonetaryValue, MonetaryValue) | Determines whether the two specified values are equal. |
| Equals(object?) | Determines whether this value is equal to the specified object. |
| GetHashCode() | Gets the hash code for this value. |
| Parse(ReadOnlySpan<char>, MonetaryStyles, IFormatProvider?) | Converts the string representation of a monetary value to its MonetaryValue equivalent using the Default currency registry. |
| Parse(ReadOnlySpan<char>, IFormatProvider?) | Converts the string representation of a monetary value to its MonetaryValue equivalent using the Default currency registry. |
| Parse(string, MonetaryStyles, IFormatProvider?) | Converts the string representation of a monetary value to its MonetaryValue equivalent using the Default currency registry. |
| Parse(string, IFormatProvider?) | Converts the string representation of a monetary value to its MonetaryValue equivalent using the Default currency registry. |
| RoundToCurrencyDigits() | Returns a value rounded to the currency's number of decimal digits using ToEven midpoint rounding ("banker's rounding"). |
| RoundToCurrencyDigits(MidpointRounding) | Returns a value rounded to the currency's number of decimal digits using the specified midpoint rounding mode. |
| ToDefaultIfZero() | Returns Default if this value's Amount is |
| ToString() | Returns a culture-dependent international string representation of this value's currency and amount. |
| ToString(string?, IFormatProvider?) | Returns a string representation of this value's currency and amount. |
| TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?) | Formats this value's currency and amount into a span of characters. |
| TryParse(ReadOnlySpan<char>, MonetaryStyles, IFormatProvider?, out MonetaryValue) | Converts the string representation of a monetary value to its MonetaryValue equivalent using the Default currency registry. |
| TryParse(ReadOnlySpan<char>, out MonetaryValue) | Converts the string representation of a monetary value to its MonetaryValue equivalent using the Default currency registry. |
| TryParse(ReadOnlySpan<char>, IFormatProvider?, out MonetaryValue) | Converts the string representation of a monetary value to its MonetaryValue equivalent using the Default currency registry. |
| TryParse(string?, MonetaryStyles, IFormatProvider?, out MonetaryValue) | Converts the string representation of a monetary value to its MonetaryValue equivalent using the Default currency registry. |
| TryParse(string?, out MonetaryValue) | Converts the string representation of a monetary value to its MonetaryValue equivalent using the Default currency registry. |
| TryParse(string?, IFormatProvider?, out MonetaryValue) | Converts the string representation of a monetary value to its MonetaryValue equivalent using the Default currency registry. |
Operators
| Name | Description |
|---|---|
| operator +(MonetaryValue, MonetaryValue) | Adds two values together to compute their sum. |
| operator +(MonetaryValue, decimal) | Adds two values together to compute their sum. |
| operator --(MonetaryValue) | Decrements a value. |
| operator /(MonetaryValue, MonetaryValue) | Divides one value by another to compute their quotient. |
| operator /(MonetaryValue, decimal) | Divides one value by another to compute their quotient. |
| operator ==(MonetaryValue, MonetaryValue) | Compares two values to determine equality. |
| operator >(MonetaryValue, MonetaryValue) | Compares two values to determine which is greater. |
| operator >=(MonetaryValue, MonetaryValue) | Compares two values to determine which is greater or equal. |
| operator ++(MonetaryValue) | Increments a value. |
| operator !=(MonetaryValue, MonetaryValue) | Compares two values to determine inequality. |
| operator <(MonetaryValue, MonetaryValue) | Compares two values to determine which is less. |
| operator <=(MonetaryValue, MonetaryValue) | Compares two values to determine which is less or equal. |
| operator *(MonetaryValue, decimal) | Multiplies two values together to compute their product. |
| operator -(MonetaryValue, MonetaryValue) | Subtracts two values to compute their difference. |
| operator -(MonetaryValue, decimal) | Subtracts two values to compute their difference. |
| operator -(MonetaryValue) | Computes the unary negation of a value. |
| operator +(MonetaryValue) | Computes the unary plus of a value. |