November Happy Hour will be moved to Thursday December 5th.

Struct Currency

Currency is an immutable struct type that encapsulates a type of currency.

Implements
System.IComparable<Currency>
System.IEquatable<Currency>
System.IComparable
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
Namespace: Mediachase.Commerce
Assembly: Mediachase.Commerce.dll
Version: 13.30.0
Syntax
public struct Currency : IComparable<Currency>, IEquatable<Currency>, IComparable
Remarks

The currency code may be no longer than 8 characters, and may not contain any digits.

Constructors

Currency(String)

Initializes a new instance of the Currency struct.

Declaration
public Currency(string currencyCode)
Parameters
Type Name Description
System.String currencyCode

The currency code.

Currency(String, NumberFormatInfo)

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

AFN

Declaration
public static readonly Currency AFN
Field Value
Type Description
Currency

ALL

Declaration
public static readonly Currency ALL
Field Value
Type Description
Currency

ANG

Declaration
public static readonly Currency ANG
Field Value
Type Description
Currency

ARS

Declaration
public static readonly Currency ARS
Field Value
Type Description
Currency

AUD

Declaration
public static readonly Currency AUD
Field Value
Type Description
Currency

AWG

Declaration
public static readonly Currency AWG
Field Value
Type Description
Currency

AZN

Declaration
public static readonly Currency AZN
Field Value
Type Description
Currency

BAM

Declaration
public static readonly Currency BAM
Field Value
Type Description
Currency

BBD

Declaration
public static readonly Currency BBD
Field Value
Type Description
Currency

BGN

Declaration
public static readonly Currency BGN
Field Value
Type Description
Currency

BMD

Declaration
public static readonly Currency BMD
Field Value
Type Description
Currency

BND

Declaration
public static readonly Currency BND
Field Value
Type Description
Currency

BOB

Declaration
public static readonly Currency BOB
Field Value
Type Description
Currency

BRL

Declaration
public static readonly Currency BRL
Field Value
Type Description
Currency

BSD

Declaration
public static readonly Currency BSD
Field Value
Type Description
Currency

BWP

Declaration
public static readonly Currency BWP
Field Value
Type Description
Currency

BYR

Declaration
public static readonly Currency BYR
Field Value
Type Description
Currency

BZD

Declaration
public static readonly Currency BZD
Field Value
Type Description
Currency

CAD

Declaration
public static readonly Currency CAD
Field Value
Type Description
Currency

CHF

Declaration
public static readonly Currency CHF
Field Value
Type Description
Currency

CLP

Declaration
public static readonly Currency CLP
Field Value
Type Description
Currency

CNY

Declaration
public static readonly Currency CNY
Field Value
Type Description
Currency

COP

Declaration
public static readonly Currency COP
Field Value
Type Description
Currency

CRC

Declaration
public static readonly Currency CRC
Field Value
Type Description
Currency

CUP

Declaration
public static readonly Currency CUP
Field Value
Type Description
Currency

CZK

Declaration
public static readonly Currency CZK
Field Value
Type Description
Currency

DKK

Declaration
public static readonly Currency DKK
Field Value
Type Description
Currency

DOP

Declaration
public static readonly Currency DOP
Field Value
Type Description
Currency

EEK

Declaration
public static readonly Currency EEK
Field Value
Type Description
Currency

EGP

Declaration
public static readonly Currency EGP
Field Value
Type Description
Currency

Empty

Declaration
public static readonly Currency Empty
Field Value
Type Description
Currency

EUR

Declaration
public static readonly Currency EUR
Field Value
Type Description
Currency

FallbackFormatCode

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
Remarks

Formatting information can be added and modified by calling SetFormat(string currencyCode, NumberFormatInfo format).

FJD

Declaration
public static readonly Currency FJD
Field Value
Type Description
Currency

FKP

Declaration
public static readonly Currency FKP
Field Value
Type Description
Currency

GBP

Declaration
public static readonly Currency GBP
Field Value
Type Description
Currency

GGP

Declaration
public static readonly Currency GGP
Field Value
Type Description
Currency

GHC

Declaration
public static readonly Currency GHC
Field Value
Type Description
Currency

GIP

Declaration
public static readonly Currency GIP
Field Value
Type Description
Currency

GTQ

Declaration
public static readonly Currency GTQ
Field Value
Type Description
Currency

GYD

Declaration
public static readonly Currency GYD
Field Value
Type Description
Currency

HKD

Declaration
public static readonly Currency HKD
Field Value
Type Description
Currency

HNL

Declaration
public static readonly Currency HNL
Field Value
Type Description
Currency

HRK

Declaration
public static readonly Currency HRK
Field Value
Type Description
Currency

HUF

Declaration
public static readonly Currency HUF
Field Value
Type Description
Currency

IDR

Declaration
public static readonly Currency IDR
Field Value
Type Description
Currency

ILS

Declaration
public static readonly Currency ILS
Field Value
Type Description
Currency

IMP

Declaration
public static readonly Currency IMP
Field Value
Type Description
Currency

INR

Declaration
public static readonly Currency INR
Field Value
Type Description
Currency

IRR

Declaration
public static readonly Currency IRR
Field Value
Type Description
Currency

ISK

Declaration
public static readonly Currency ISK
Field Value
Type Description
Currency

JEP

Declaration
public static readonly Currency JEP
Field Value
Type Description
Currency

JMD

Declaration
public static readonly Currency JMD
Field Value
Type Description
Currency

JPY

Declaration
public static readonly Currency JPY
Field Value
Type Description
Currency

KGS

Declaration
public static readonly Currency KGS
Field Value
Type Description
Currency

KHR

Declaration
public static readonly Currency KHR
Field Value
Type Description
Currency

KPW

Declaration
public static readonly Currency KPW
Field Value
Type Description
Currency

KRW

Declaration
public static readonly Currency KRW
Field Value
Type Description
Currency

KYD

Declaration
public static readonly Currency KYD
Field Value
Type Description
Currency

KZT

Declaration
public static readonly Currency KZT
Field Value
Type Description
Currency

LAK

Declaration
public static readonly Currency LAK
Field Value
Type Description
Currency

LBP

Declaration
public static readonly Currency LBP
Field Value
Type Description
Currency

LKR

Declaration
public static readonly Currency LKR
Field Value
Type Description
Currency

LRD

Declaration
public static readonly Currency LRD
Field Value
Type Description
Currency

LTL

Declaration
public static readonly Currency LTL
Field Value
Type Description
Currency

LVL

Declaration
public static readonly Currency LVL
Field Value
Type Description
Currency

MaxCurrencyCodeLength

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

MKD

Declaration
public static readonly Currency MKD
Field Value
Type Description
Currency

MNT

Declaration
public static readonly Currency MNT
Field Value
Type Description
Currency

MUR

Declaration
public static readonly Currency MUR
Field Value
Type Description
Currency

MXN

Declaration
public static readonly Currency MXN
Field Value
Type Description
Currency

MYR

Declaration
public static readonly Currency MYR
Field Value
Type Description
Currency

MZN

Declaration
public static readonly Currency MZN
Field Value
Type Description
Currency

NAD

Declaration
public static readonly Currency NAD
Field Value
Type Description
Currency

NGN

Declaration
public static readonly Currency NGN
Field Value
Type Description
Currency

NIO

Declaration
public static readonly Currency NIO
Field Value
Type Description
Currency

NOK

Declaration
public static readonly Currency NOK
Field Value
Type Description
Currency

NPR

Declaration
public static readonly Currency NPR
Field Value
Type Description
Currency

NZD

Declaration
public static readonly Currency NZD
Field Value
Type Description
Currency

OMR

Declaration
public static readonly Currency OMR
Field Value
Type Description
Currency

PAB

Declaration
public static readonly Currency PAB
Field Value
Type Description
Currency

PEN

Declaration
public static readonly Currency PEN
Field Value
Type Description
Currency

PHP

Declaration
public static readonly Currency PHP
Field Value
Type Description
Currency

PKR

Declaration
public static readonly Currency PKR
Field Value
Type Description
Currency

PLN

Declaration
public static readonly Currency PLN
Field Value
Type Description
Currency

PYG

Declaration
public static readonly Currency PYG
Field Value
Type Description
Currency

QAR

Declaration
public static readonly Currency QAR
Field Value
Type Description
Currency

RON

Declaration
public static readonly Currency RON
Field Value
Type Description
Currency

RSD

Declaration
public static readonly Currency RSD
Field Value
Type Description
Currency

RUB

Declaration
public static readonly Currency RUB
Field Value
Type Description
Currency

SAR

Declaration
public static readonly Currency SAR
Field Value
Type Description
Currency

SBD

Declaration
public static readonly Currency SBD
Field Value
Type Description
Currency

SCR

Declaration
public static readonly Currency SCR
Field Value
Type Description
Currency

SEK

Declaration
public static readonly Currency SEK
Field Value
Type Description
Currency

SGD

Declaration
public static readonly Currency SGD
Field Value
Type Description
Currency

SHP

Declaration
public static readonly Currency SHP
Field Value
Type Description
Currency

SOS

Declaration
public static readonly Currency SOS
Field Value
Type Description
Currency

SRD

Declaration
public static readonly Currency SRD
Field Value
Type Description
Currency

SVC

Declaration
public static readonly Currency SVC
Field Value
Type Description
Currency

SYP

Declaration
public static readonly Currency SYP
Field Value
Type Description
Currency

THB

Declaration
public static readonly Currency THB
Field Value
Type Description
Currency

TRL

Declaration
public static readonly Currency TRL
Field Value
Type Description
Currency

TRY

Declaration
public static readonly Currency TRY
Field Value
Type Description
Currency

TTD

Declaration
public static readonly Currency TTD
Field Value
Type Description
Currency

TVD

Declaration
public static readonly Currency TVD
Field Value
Type Description
Currency

TWD

Declaration
public static readonly Currency TWD
Field Value
Type Description
Currency

UAH

Declaration
public static readonly Currency UAH
Field Value
Type Description
Currency

USD

Declaration
public static readonly Currency USD
Field Value
Type Description
Currency

UYU

Declaration
public static readonly Currency UYU
Field Value
Type Description
Currency

UZS

Declaration
public static readonly Currency UZS
Field Value
Type Description
Currency

VEF

Declaration
public static readonly Currency VEF
Field Value
Type Description
Currency

VND

Declaration
public static readonly Currency VND
Field Value
Type Description
Currency

XCD

Declaration
public static readonly Currency XCD
Field Value
Type Description
Currency

YER

Declaration
public static readonly Currency YER
Field Value
Type Description
Currency

ZAR

Declaration
public static readonly Currency ZAR
Field Value
Type Description
Currency

ZWD

Declaration
public static readonly Currency ZWD
Field Value
Type Description
Currency

Properties

CurrencyCode

Gets the currency code.

Declaration
public string CurrencyCode { get; }
Property Value
Type Description
System.String

Format

Gets the currency format.

Declaration
public NumberFormatInfo Format { get; }
Property Value
Type Description
System.Globalization.NumberFormatInfo
Remarks

Used to get a NumberFormatInfo for formatting currency values.

IsEmpty

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.

Remarks

If we initialize a Currency with an empty string (or it gets created by default constructor) this property will return true, indicating that we do not have a proper CurrencyCode set.

LowestDenomination

Gets the lowest denomination for the currency.

Declaration
public decimal LowestDenomination { get; }
Property Value
Type Description
System.Decimal

Methods

CompareTo(Currency)

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.

Equals(Currency)

Declaration
public bool Equals(Currency other)
Parameters
Type Name Description
Currency other
Returns
Type Description
System.Boolean

Equals(Object)

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)

GetHashCode()

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()

Percentage(Decimal, Decimal)

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.

Percentage(Decimal, Double)

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.

Round(Decimal)

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.

Round(Decimal, Int32)

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.

SetFormat(String, NumberFormatInfo)

Sets a currency format.

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.

ToString()

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

Equality(Currency, Currency)

Declaration
public static bool operator ==(Currency c1, Currency c2)
Parameters
Type Name Description
Currency c1
Currency c2
Returns
Type Description
System.Boolean

GreaterThan(Currency, Currency)

Declaration
public static bool operator>(Currency c1, Currency c2)
Parameters
Type Name Description
Currency c1
Currency c2
Returns
Type Description
System.Boolean

GreaterThanOrEqual(Currency, Currency)

Declaration
public static bool operator >=(Currency c1, Currency c2)
Parameters
Type Name Description
Currency c1
Currency c2
Returns
Type Description
System.Boolean

Implicit(Currency to String)

Declaration
public static implicit operator string (Currency c)
Parameters
Type Name Description
Currency c
Returns
Type Description
System.String

Implicit(String to Currency)

Declaration
public static implicit operator Currency(string s)
Parameters
Type Name Description
System.String s
Returns
Type Description
Currency

Inequality(Currency, Currency)

Declaration
public static bool operator !=(Currency c1, Currency c2)
Parameters
Type Name Description
Currency c1
Currency c2
Returns
Type Description
System.Boolean

LessThan(Currency, Currency)

Declaration
public static bool operator <(Currency c1, Currency c2)
Parameters
Type Name Description
Currency c1
Currency c2
Returns
Type Description
System.Boolean

LessThanOrEqual(Currency, Currency)

Declaration
public static bool operator <=(Currency c1, Currency c2)
Parameters
Type Name Description
Currency c1
Currency c2
Returns
Type Description
System.Boolean

Explicit Interface Implementations

IComparable.CompareTo(Object)

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