本文整理汇总了C#中System.Decimal.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# Decimal.CompareTo方法的具体用法?C# Decimal.CompareTo怎么用?C# Decimal.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Decimal
的用法示例。
在下文中一共展示了Decimal.CompareTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SqlMoney
/**
* Initializes a new instance of the SqlMoney instance using the supplied Decimal value.
* @param value The Decimal value to be stored as a SqlMoney instance.
*/
public SqlMoney(Decimal value)
{
if ((value.CompareTo(MaxValue.Value) > 0 || value.CompareTo(MinValue.Value) < 0))
throw new OverflowException("overflow - the value is out of range " + value);
_value = value;
_isNull = false;
}
示例2: encodeBigDecimal
public virtual void encodeBigDecimal(Decimal bd)
{
int scale;
Decimal temp;
ConvertToScaledDecimal(bd, out scale, out temp);
if (temp.CompareTo(long.MinValue) > 0 && temp.CompareTo(long.MaxValue) < 0)
encodeLong((long)temp, scale);
else
{
BigInteger bi = new BigInteger(Decimal.Truncate(Math.Abs(temp)).ToString(), 10);
byte[] byteArray = bi.ToByteArray();
write(edsScaledCount2);
write(scale);
write(bd.CompareTo(Decimal.Zero));
write(byteArray.Length);
write(byteArray);
}
}
示例3: ValidateFrequency
/// <summary>
/// Validates the frequency. Throws an <see cref="ArgumentOutOfRangeException"/>
/// if the frequency is not in range.
/// </summary>
/// <param name="freq">
/// The frequency to validate.
/// </param>
/// <exception cref="ArgumentOutOfRangeException">
/// <paramref name="freq"/> must be between 40Hz and 1000Hz.
/// </exception>
private void ValidateFrequency(Decimal freq) {
if ((freq.CompareTo(MIN_FREQUENCY) == -1) || (freq.CompareTo(MAX_FREQUENCY) == 1)) {
throw new ArgumentOutOfRangeException("Frequency [" + freq.ToString() + "] must be between 40.0 and 1000.0 Hz.");
}
}
示例4: Between
/// <summary>
/// A T extension method that check if the value is between (exclusif) the minValue and maxValue.
/// </summary>
/// <param name="this">The @this to act on.</param>
/// <param name="minValue">The minimum value.</param>
/// <param name="maxValue">The maximum value.</param>
/// <returns>true if the value is between the minValue and maxValue, otherwise false.</returns>
/// ###
/// <typeparam name="T">Generic type parameter.</typeparam>
public static bool Between(this Decimal @this, Decimal minValue, Decimal maxValue)
{
return minValue.CompareTo(@this) == -1 && @this.CompareTo(maxValue) == -1;
}