本文整理汇总了C#中System.Double.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# Double.CompareTo方法的具体用法?C# Double.CompareTo怎么用?C# Double.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Double
的用法示例。
在下文中一共展示了Double.CompareTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCompare
private static void TestCompare(Double a, Double b)
{
String di = a.CompareTo(b).ToString() + ' ' + b.CompareTo(a).ToString();
BigNum na = a;
BigNum nb = b;
String ni = na.CompareTo(nb).ToString() + ' ' + nb.CompareTo(na).ToString();
Console.WriteLine("{0,18} comp {1,18} = {2,18} : {3,18} -> {4}", a, b, di, ni, di == ni ? "Pass" : "Fail" );
}
示例2: 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 Double @this, Double minValue, Double maxValue)
{
return minValue.CompareTo(@this) == -1 && @this.CompareTo(maxValue) == -1;
}