Currency
Namespace Mc.Scripting.Services · Kind class (sealed)
public sealed class Currency : IEquatable<Currency>A currency. Amounts are long minor units (cents when Currency.FractionDigits is 2): no floating point on any path.
Constructors
Section titled “Constructors”| Member | Description |
|---|---|
Currency(string Name, string Symbol, int FractionDigits, string PluralName) |
A currency. |
Constructor
Section titled “Constructor”public Currency(string Name, string Symbol, int FractionDigits, string PluralName)A currency. Amounts are long minor units (cents when Currency.FractionDigits is 2): no floating point on any path.
Parameters
| Name | Type | Description |
|---|---|---|
Name |
string |
The name (“dollar”). |
Symbol |
string |
The symbol written before the amount (“$”). |
FractionDigits |
int |
Minor units per major unit as a power of ten (2 = cents), 0 to 9. |
PluralName |
string |
The plural name (“dollars”). |
Properties
Section titled “Properties”| Member | Description |
|---|---|
int FractionDigits { get; init; } |
Minor units per major unit as a power of ten, 0 to 9 (checked when the currency is made). |
string Name { get; init; } |
The name (“dollar”). |
string PluralName { get; init; } |
The plural name (“dollars”). |
string Symbol { get; init; } |
The symbol written before the amount (“$”). |
FractionDigits
Section titled “FractionDigits”public int FractionDigits { get; init; }Minor units per major unit as a power of ten, 0 to 9 (checked when the currency is made).
Throws
System.ArgumentOutOfRangeException: The digits are outside 0 to 9.
public string Name { get; init; }The name (“dollar”).
PluralName
Section titled “PluralName”public string PluralName { get; init; }The plural name (“dollars”).
Symbol
Section titled “Symbol”public string Symbol { get; init; }The symbol written before the amount (“$”).
Methods
Section titled “Methods”| Member | Description |
|---|---|
string Format(long minor) |
The amount as text: the symbol, the major units and the minor units after a point (“$12.05”). |
Format
Section titled “Format”public string Format(long minor)The amount as text: the symbol, the major units and the minor units after a point (“$12.05”). Negative amounts start with a minus sign.
Parameters
| Name | Type | Description |
|---|---|---|
minor |
long |
The amount in minor units. |
Returns string: The text.