MoneyParseOptions Class
Definition
Configures how Parse(string, MoneyParseOptions) and its TryParse counterpart interpret
monetary text.
public sealed record MoneyParseOptions : IEquatable<MoneyParseOptions>
- Inheritance
-
MoneyParseOptions
- Implements
- Inherited Members
- Extension Methods
Remarks
using Bodu.Financial;
// RoundTripOnly pairs with the "R" format specifier for storage and wire formats.
var wire = Money.From(1234.56m, CurrencyCode.USD).ToString("R"); // "USD 1234.56"
Money restored = Money.Parse(wire, new MoneyParseOptions { Mode = MoneyParseMode.RoundTripOnly });
// LenientImport trims white space and upcases the ISO code - for spreadsheets and external feeds.
Money imported = Money.Parse(" 1234.56 usd ", new MoneyParseOptions { Mode = MoneyParseMode.LenientImport });
Constructors
MoneyParseOptions()
public MoneyParseOptions()
Properties
CurrencyLookup
Gets the currency lookup used to resolve symbols under CultureAware, or null to use a default CurrencyLookupService.
public ICurrencyLookup? CurrencyLookup { get; init; }
Property Value
- ICurrencyLookup
The configured lookup, or null.
Default
Gets the shared default options: strict ISO parsing, current-culture numeric interpretation, and rejection of unregistered currencies.
public static MoneyParseOptions Default { get; }
Property Value
- MoneyParseOptions
The default MoneyParseOptions.
FormatProvider
Gets the culture used to interpret the numeric component, or null to select the mode's default (current culture, or invariant culture for RoundTripOnly).
public IFormatProvider? FormatProvider { get; init; }
Property Value
- IFormatProvider
The configured format provider, or null.
Mode
Gets the parse mode applied to the input.
public MoneyParseMode Mode { get; init; }
Property Value
- MoneyParseMode
The configured MoneyParseMode.
Methods
Equals(MoneyParseOptions?)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(MoneyParseOptions? other)
Parameters
otherMoneyParseOptionsAn object to compare with this object.
Returns
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
Operators
operator ==(MoneyParseOptions?, MoneyParseOptions?)
public static bool operator ==(MoneyParseOptions? left, MoneyParseOptions? right)
Parameters
leftMoneyParseOptionsrightMoneyParseOptions
Returns
operator !=(MoneyParseOptions?, MoneyParseOptions?)
public static bool operator !=(MoneyParseOptions? left, MoneyParseOptions? right)
Parameters
leftMoneyParseOptionsrightMoneyParseOptions
Returns
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |