當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。