Struct Currency
Currency is an immutable struct type that encapsulates a type of currency.
Implements
System.IComparable
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
Assembly: Mediachase.Commerce.dll
Version: 13.30.0
public struct Currency : IComparable<Currency>, IEquatable<Currency>, IComparable
Constructors
Initializes a new instance of the Currency struct.
Declaration
public Currency(string currencyCode)
Parameters
Type |
Name |
Description |
System.String |
currencyCode |
The currency code.
|
Initializes a new instance of the Currency struct.
Declaration
public Currency(string currencyCode, NumberFormatInfo format)
Parameters
Type |
Name |
Description |
System.String |
currencyCode |
The currency code.
|
System.Globalization.NumberFormatInfo |
format |
The NumberFormatInfo instance that describes how to format this currency.
|
Exceptions
Type |
Condition |
System.ArgumentNullException |
currencyCode
|
System.ArgumentException |
|
Fields
Declaration
public static readonly Currency AFN
Field Value
Declaration
public static readonly Currency ALL
Field Value
Declaration
public static readonly Currency ANG
Field Value
Declaration
public static readonly Currency ARS
Field Value
Declaration
public static readonly Currency AUD
Field Value
Declaration
public static readonly Currency AWG
Field Value
Declaration
public static readonly Currency AZN
Field Value
Declaration
public static readonly Currency BAM
Field Value
Declaration
public static readonly Currency BBD
Field Value
Declaration
public static readonly Currency BGN
Field Value
Declaration
public static readonly Currency BMD
Field Value
Declaration
public static readonly Currency BND
Field Value
Declaration
public static readonly Currency BOB
Field Value
Declaration
public static readonly Currency BRL
Field Value
Declaration
public static readonly Currency BSD
Field Value
Declaration
public static readonly Currency BWP
Field Value
Declaration
public static readonly Currency BYR
Field Value
Declaration
public static readonly Currency BZD
Field Value
Declaration
public static readonly Currency CAD
Field Value
Declaration
public static readonly Currency CHF
Field Value
Declaration
public static readonly Currency CLP
Field Value
Declaration
public static readonly Currency CNY
Field Value
Declaration
public static readonly Currency COP
Field Value
Declaration
public static readonly Currency CRC
Field Value
Declaration
public static readonly Currency CUP
Field Value
Declaration
public static readonly Currency CZK
Field Value
Declaration
public static readonly Currency DKK
Field Value
Declaration
public static readonly Currency DOP
Field Value
Declaration
public static readonly Currency EEK
Field Value
Declaration
public static readonly Currency EGP
Field Value
Declaration
public static readonly Currency Empty
Field Value
Declaration
public static readonly Currency EUR
Field Value
If we have a currency that does not have a matching Format, use the format associated with this currency code.
Declaration
public const string FallbackFormatCode = ""
Field Value
Type |
Description |
System.String |
|
Declaration
public static readonly Currency FJD
Field Value
Declaration
public static readonly Currency FKP
Field Value
Declaration
public static readonly Currency GBP
Field Value
Declaration
public static readonly Currency GGP
Field Value
Declaration
public static readonly Currency GHC
Field Value
Declaration
public static readonly Currency GIP
Field Value
Declaration
public static readonly Currency GTQ
Field Value
Declaration
public static readonly Currency GYD
Field Value
Declaration
public static readonly Currency HKD
Field Value
Declaration
public static readonly Currency HNL
Field Value
Declaration
public static readonly Currency HRK
Field Value
Declaration
public static readonly Currency HUF
Field Value
Declaration
public static readonly Currency IDR
Field Value
Declaration
public static readonly Currency ILS
Field Value
Declaration
public static readonly Currency IMP
Field Value
Declaration
public static readonly Currency INR
Field Value
Declaration
public static readonly Currency IRR
Field Value
Declaration
public static readonly Currency ISK
Field Value
Declaration
public static readonly Currency JEP
Field Value
Declaration
public static readonly Currency JMD
Field Value
Declaration
public static readonly Currency JPY
Field Value
Declaration
public static readonly Currency KGS
Field Value
Declaration
public static readonly Currency KHR
Field Value
Declaration
public static readonly Currency KPW
Field Value
Declaration
public static readonly Currency KRW
Field Value
Declaration
public static readonly Currency KYD
Field Value
Declaration
public static readonly Currency KZT
Field Value
Declaration
public static readonly Currency LAK
Field Value
Declaration
public static readonly Currency LBP
Field Value
Declaration
public static readonly Currency LKR
Field Value
Declaration
public static readonly Currency LRD
Field Value
Declaration
public static readonly Currency LTL
Field Value
Declaration
public static readonly Currency LVL
Field Value
Max length of the currency code when you create a new currency struct.
Declaration
public const int MaxCurrencyCodeLength = 8
Field Value
Type |
Description |
System.Int32 |
|
Declaration
public static readonly Currency MKD
Field Value
Declaration
public static readonly Currency MNT
Field Value
Declaration
public static readonly Currency MUR
Field Value
Declaration
public static readonly Currency MXN
Field Value
Declaration
public static readonly Currency MYR
Field Value
Declaration
public static readonly Currency MZN
Field Value
Declaration
public static readonly Currency NAD
Field Value
Declaration
public static readonly Currency NGN
Field Value
Declaration
public static readonly Currency NIO
Field Value
Declaration
public static readonly Currency NOK
Field Value
Declaration
public static readonly Currency NPR
Field Value
Declaration
public static readonly Currency NZD
Field Value
Declaration
public static readonly Currency OMR
Field Value
Declaration
public static readonly Currency PAB
Field Value
Declaration
public static readonly Currency PEN
Field Value
Declaration
public static readonly Currency PHP
Field Value
Declaration
public static readonly Currency PKR
Field Value
Declaration
public static readonly Currency PLN
Field Value
Declaration
public static readonly Currency PYG
Field Value
Declaration
public static readonly Currency QAR
Field Value
Declaration
public static readonly Currency RON
Field Value
Declaration
public static readonly Currency RSD
Field Value
Declaration
public static readonly Currency RUB
Field Value
Declaration
public static readonly Currency SAR
Field Value
Declaration
public static readonly Currency SBD
Field Value
Declaration
public static readonly Currency SCR
Field Value
Declaration
public static readonly Currency SEK
Field Value
Declaration
public static readonly Currency SGD
Field Value
Declaration
public static readonly Currency SHP
Field Value
Declaration
public static readonly Currency SOS
Field Value
Declaration
public static readonly Currency SRD
Field Value
Declaration
public static readonly Currency SVC
Field Value
Declaration
public static readonly Currency SYP
Field Value
Declaration
public static readonly Currency THB
Field Value
Declaration
public static readonly Currency TRL
Field Value
Declaration
public static readonly Currency TRY
Field Value
Declaration
public static readonly Currency TTD
Field Value
Declaration
public static readonly Currency TVD
Field Value
Declaration
public static readonly Currency TWD
Field Value
Declaration
public static readonly Currency UAH
Field Value
Declaration
public static readonly Currency USD
Field Value
Declaration
public static readonly Currency UYU
Field Value
Declaration
public static readonly Currency UZS
Field Value
Declaration
public static readonly Currency VEF
Field Value
Declaration
public static readonly Currency VND
Field Value
Declaration
public static readonly Currency XCD
Field Value
Declaration
public static readonly Currency YER
Field Value
Declaration
public static readonly Currency ZAR
Field Value
Declaration
public static readonly Currency ZWD
Field Value
Properties
Declaration
public string CurrencyCode { get; }
Property Value
Type |
Description |
System.String |
|
Gets the currency format.
Declaration
public NumberFormatInfo Format { get; }
Property Value
Type |
Description |
System.Globalization.NumberFormatInfo |
|
Gets a value indicating whether this instance is empty.
Declaration
public bool IsEmpty { get; }
Property Value
Type |
Description |
System.Boolean |
true if this instance is empty; otherwise, false .
|
Gets the lowest denomination for the currency.
Declaration
public decimal LowestDenomination { get; }
Property Value
Type |
Description |
System.Decimal |
|
Methods
Compares currency instances for ordering purposes.
Declaration
public int CompareTo(Currency other)
Parameters
Type |
Name |
Description |
Currency |
other |
The other currency to compare against.
|
Returns
Type |
Description |
System.Int32 |
A value that indicates the relative order of the objects being compared.
The return value has the following meanings: Value Meaning Less than zero
This object is less than the other parameter.Zero This object is equal to
other. Greater than zero This object is greater than other.
|
Declaration
public bool Equals(Currency other)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Determines whether the specified System.Object is equal to this instance.
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
The System.Object to compare with this instance.
|
Returns
Type |
Description |
System.Boolean |
true if the specified System.Object is equal to this instance; otherwise, false .
|
Overrides
System.ValueType.Equals(System.Object)
Returns a hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
|
Overrides
System.ValueType.GetHashCode()
Get percentage of amount, following its currency's format.
Declaration
public decimal Percentage(decimal amount, decimal percentage)
Parameters
Type |
Name |
Description |
System.Decimal |
amount |
A decimal number to be percentage.
|
System.Decimal |
percentage |
The percentage number.
|
Returns
Type |
Description |
System.Decimal |
The rounded amount after calculate percentage following currency's format.
|
Get percentage of amount, following its currency's format.
Declaration
public decimal Percentage(decimal amount, double percentage)
Parameters
Type |
Name |
Description |
System.Decimal |
amount |
A decimal number to be percentage.
|
System.Double |
percentage |
The percentage number.
|
Returns
Type |
Description |
System.Decimal |
The rounded amount after calculate percentage following currency's format.
|
Rounds a decimal value, following a specific currency's format.
Declaration
public decimal Round(decimal amount)
Parameters
Type |
Name |
Description |
System.Decimal |
amount |
A decimal number to be rounded.
|
Returns
Type |
Description |
System.Decimal |
Rounded amount following the standard currency decimal digits format.
|
Rounds a decimal value to a specified number of fractional digits.
Declaration
public decimal Round(decimal amount, int decimalDigits)
Parameters
Type |
Name |
Description |
System.Decimal |
amount |
A decimal number to be rounded.
|
System.Int32 |
decimalDigits |
The number of decimal places to use in return value.
|
Returns
Type |
Description |
System.Decimal |
The rounded amount base on decimal digits to be used.
|
Declaration
public static void SetFormat(string currencyCode, NumberFormatInfo format)
Parameters
Type |
Name |
Description |
System.String |
currencyCode |
The currency code.
|
System.Globalization.NumberFormatInfo |
format |
The format to use for this currency.
|
Returns a System.String that represents this instance.
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
A System.String that represents this instance.
|
Overrides
System.ValueType.ToString()
Operators
Declaration
public static bool operator ==(Currency c1, Currency c2)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Declaration
public static bool operator>(Currency c1, Currency c2)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Declaration
public static bool operator >=(Currency c1, Currency c2)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Declaration
public static implicit operator string (Currency c)
Parameters
Returns
Type |
Description |
System.String |
|
Declaration
public static implicit operator Currency(string s)
Parameters
Type |
Name |
Description |
System.String |
s |
|
Returns
Declaration
public static bool operator !=(Currency c1, Currency c2)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Declaration
public static bool operator <(Currency c1, Currency c2)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Declaration
public static bool operator <=(Currency c1, Currency c2)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Explicit Interface Implementations
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
Declaration
int IComparable.CompareTo(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
An object to compare with this instance.
|
Returns
Type |
Description |
System.Int32 |
A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance is less than obj . Zero This instance is equal to obj . Greater than zero This instance is greater than obj .
|
Exceptions
Type |
Condition |
System.ArgumentException |
obj is not the same type as this instance.
|
Implements
System.IComparable<T>
System.IEquatable<T>
System.IComparable