本文整理汇总了C#中System.Tuple<T1>.IComparable.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# Tuple<T1>.IComparable.CompareTo方法的具体用法?C# Tuple<T1>.IComparable.CompareTo怎么用?C# Tuple<T1>.IComparable.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了Tuple<T1>.IComparable.CompareTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
class Example
{
static void Main()
{
Tuple<Double>[] values = { Tuple.Create(13.54),
Tuple.Create(Double.NaN),
Tuple.Create(-189.42993),
Tuple.Create(Double.PositiveInfinity),
Tuple.Create(Double.Epsilon),
Tuple.Create(1.934E-17),
Tuple.Create(Double.NegativeInfinity),
Tuple.Create(-0.000000000003588),
null };
Console.WriteLine("The values in unsorted order:");
foreach (var value in values)
if (value != null)
Console.WriteLine(" {0}", value.Item1);
else
Console.WriteLine(" <null>");
Console.WriteLine();
Array.Sort(values);
Console.WriteLine("The values in sorted order:");
foreach (var value in values)
if (value != null)
Console.WriteLine(" {0}", value.Item1);
else
Console.WriteLine(" <null>");
}
}
输出:
The values in unsorted order: 13.54 NaN -189.42993 Infinity 4.94065645841247E-324 1.934E-17 -Infinity -3.588E-12 The values in sorted order: NaN -Infinity -189.42993 -3.588E-12 4.94065645841247E-324 1.934E-17 13.54 Infinity