本文整理匯總了C#中System.Numerics.BigInteger.IComparable.CompareTo方法的典型用法代碼示例。如果您正苦於以下問題:C# BigInteger.IComparable.CompareTo方法的具體用法?C# BigInteger.IComparable.CompareTo怎麽用?C# BigInteger.IComparable.CompareTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Numerics.BigInteger
的用法示例。
在下文中一共展示了BigInteger.IComparable.CompareTo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: foreach
object[] values = { BigInteger.Pow(Int64.MaxValue, 10), null,
12.534, Int64.MaxValue, BigInteger.One };
BigInteger number = UInt64.MaxValue;
foreach (object value in values)
{
try {
Console.WriteLine("Comparing {0} with '{1}': {2}", number, value,
number.CompareTo(value));
}
catch (ArgumentException) {
Console.WriteLine("Unable to compare the {0} value {1} with a BigInteger.",
value.GetType().Name, value);
}
}
輸出:
Comparing 18446744073709551615 with '4.4555084156466750133735972424E+189': -1 Comparing 18446744073709551615 with '': 1 Unable to compare the Double value 12.534 with a BigInteger. Unable to compare the Int64 value 9223372036854775807 with a BigInteger. Comparing 18446744073709551615 with '1': 1