MoneyRange

Field: static readonly MoneyRange Default

Expresses the default MoneyRange value. The starting Money value is the default Money value. End Money value is the greatest Money value.

    MoneyRange.Default; //0XXX - 79,228,162,514,264,337,593,543,950,335XXX

Method: static MoneyRange Parse(String)

creates a MoneyRange object with the quantity and currency starting and ending values ​​of the string .

    MoneyRange.Parse("100TRY-200TRY"); //100 TRY - 200 TRY
Parameter Name Description
moneyRangeString start-end amount and currency to be parse

Error Type: ArgumentNullException (This error is thrown if the value set to null.)

Error Type: FormatException (This error is thrown if it comes in a format outside the <MoneyFormat>-<MoneyFormat> format.)


Method: static MoneyRange Parse(String, MoneyParseType)

creates a MoneyRange object with the quantity and currency starting and ending values ​​of the string .

Decimal point preference changeable.

    MoneyRange.Parse("100.00CLP-101.00CLP", MoneyParseType.ExpectDecimalPointOnlyWhenThereAreDecimalDigits); //100.00 CLP-101.00 CLP
    MoneyRange.Parse("100CLP-101CLP", MoneyParseType.ExpectDecimalPointOnlyWhenThereAreDecimalDigits); //100 CLP-101 CLP

    MoneyRange.Parse("100.00CLP-101.00CLP", MoneyParseType.TreatLastTwoDigitsAsDecimalDigitsWhenThereIsNoDecimalPoint); //100.00 CLP-101.00 CLP
    MoneyRange.Parse("100CLP-101CLP", MoneyParseType.TreatLastTwoDigitsAsDecimalDigitsWhenThereIsNoDecimalPoint); //1 CLP-1.01 CLP
Parameter Name Description
moneyRangeString start-end amount and currency to be parse
parseType the method to be used in the parse process. ExpectDecimalPointOnlyWhenThereAreDecimalDigits(1), TreatLastTwoDigitsAsDecimalDigitsWhenThereIsNoDecimalPoint(2)

Error Type: ArgumentNullException (This error is thrown if the value set to null.)

Error Type: FormatException (This error is thrown if it comes in a format outside the <MoneyFormat>-<MoneyFormat> format.)


Constructor(Money, Money)

The MoneyRange object is created with the Money objects that start and finish given.

    new MoneyRange(100.TRY(),200.TRY()));

The start value can not be greater than the end value.

    var start = 200.TRY();
    var end = 100.TRY();

    new MoneyRange(start, end); //RangeException<MoneyRange>

Values ​​can not be less than zero.

    new MoneyRange(-100.TRY(), 100.TRY()); //RangeException<MoneyRange>
    new MoneyRange(-100.TRY(), -50.TRY()); //RangeException<MoneyRange>

MoneyRange can not be created with money in two different currency .

    MoneyRange.Parse("1000TRY-2000USD"); //InvalidCurrencyException

If one of the given moneys has the currency and the other does not, the single currency is used.

    MoneyRange.Parse("100-200TRY").Start; //1 TRY
    MoneyRange.Parse("100TRY-200").End; //2 TRY
Parameter Name Description
start Start value in Money type
end End value in Money type

Property: Money Start

Returns the start value of the Money type of the range


Property: Money End

Returns the end value of the Money type of the range


Property: CurrencyCode Currency

Returns the currency of the Money values ​​in the range.


Method: bool Contains(Money)

Returns true if the money value is in range, false otherwise.

If the value is equal to the start value or the end value, it is accepted within the range.

    new MoneyRange(100.TRY(), 100.TRY()).Contains(100.TRY()); //true
    new MoneyRange(100.TRY(), 200.TRY()).Contains(100.TRY()); //true
    new MoneyRange(0.TRY(), 100.TRY()).Contains(100.TRY());   //true
    new MoneyRange(0.TRY(), 200.TRY()).Contains(100.TRY());   //true

    new MoneyRange(100.TRY(), 200.TRY()).Contains(201.TRY()); //false
    new MoneyRange(100.TRY(), 200.TRY()).Contains(99.TRY());  //false
Parameter Name Description
money Object in Money type

Method: string ToString()

Returns the string as a string.


            new MoneyRange(6000.60.TRY(), 6000.70.TRY()).ToString(true); //6000.60TRY-6000.70TRY

Method: string ToString(Boolean)

The data is returned in string type and formatted.


            Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR");
            new MoneyRange(6000.60.TRY(), 6000.70.TRY()).ToString(true); //6.000,60 ₺ - 6.000,70 ₺

            Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
            new MoneyRange(6000.60.TRY(), 6000.70.TRY()).ToString(true); //6 000,60 ₺ - 6 000,70 ₺

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            new MoneyRange(6000.60.TRY(), 6000.70.TRY()).ToString(true); //₺ 6,000.60 - ₺ 6,000.70
Parameter Name Description
format bool type format option

Method: string ToString(MoneyFormatOptions)

Returns the string as a string. The format preference may vary when converting data to string type.

    new MoneyRange(6.60.TRY(), 6.70.TRY()).ToString(MoneyFormatOptions.ForceDecimalPoint); //6.60TRY-6.70TRY

    Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR");
    new MoneyRange(6000.60.TRY(), 6000.70.TRY()).ToString(MoneyFormatOptions.Format); //6.000,60 ₺ - 6.000,70 ₺

    Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
    new MoneyRange(6000.60.TRY(), 6000.70.TRY()).ToString(MoneyFormatOptions.Format); //6 000,60 ₺ - 6 000,70 ₺

    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
    new MoneyRange(6000.60.TRY(), 6000.70.TRY()).ToString(MoneyFormatOptions.Format); //₺ 6,000.60 - ₺ 6,000.70
Parameter Name Description
options Format information in MoneyFormatOptions(enum) type . None(0), ForceDecimalPoint(1),Format(2)

Method: bool Equals(Object)

Returns true if the given object has the same value as the MoneyRange object and the data, false otherwise.

Parameter Name Description
obj Object to be compared

Method: bool Equals(MoneyRange)

Returns true if the given MoneyRange object has the same value as the data, false otherwise.

Parameter Name Description
other The object of type MoneyRange to be compared