Table of Contents

MoneyParseOptions Class

Definition

Namespace
Bodu.Financial
Assembly
Bodu.Financial.dll
Package
Bodu.Financial 1.0.0
Source
MoneyParseOptions.cs

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

other MoneyParseOptions

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

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

left MoneyParseOptions
right MoneyParseOptions

Returns

bool

operator !=(MoneyParseOptions?, MoneyParseOptions?)

public static bool operator !=(MoneyParseOptions? left, MoneyParseOptions? right)

Parameters

left MoneyParseOptions
right MoneyParseOptions

Returns

bool

Applies to

ProductVersions
.NET8, 10