当前位置: 首页>>代码示例>>C#>>正文


C# Decimal.CompareTo方法代码示例

本文整理汇总了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;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:SqlMoney.cs

示例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);
            }
        }
开发者ID:helluvamatt,项目名称:nuodb-dotnet,代码行数:19,代码来源:EncodedDataStream.cs

示例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.");
			}
		}
开发者ID:cyrusbuilt,项目名称:MonoPi,代码行数:15,代码来源:PCA9685GpioProvider.cs

示例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;
 }
开发者ID:ChuangYang,项目名称:Z.ExtensionMethods,代码行数:13,代码来源:Decimal.Between.cs


注:本文中的System.Decimal.CompareTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。