本文整理汇总了C#中GSM.OrderByDescending方法的典型用法代码示例。如果您正苦于以下问题:C# GSM.OrderByDescending方法的具体用法?C# GSM.OrderByDescending怎么用?C# GSM.OrderByDescending使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GSM
的用法示例。
在下文中一共展示了GSM.OrderByDescending方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
// Array of 5 GSMs
GSM[] testPhones = new GSM[5];
// Random generated phones, based on a given pre-set of data
for (int i = 0; i < 5; i++)
{
testPhones[i] = new GSM(company[pickRnd.Next(0, company.Length)],
"Model S" + (i + 1), owner[pickRnd.Next(0, owner.Length)],
300 + (i * 50), displays[pickRnd.Next(0, displays.Length)],
batteries[pickRnd.Next(0, batteries.Length)]);
}
// Displaying some information about the phones
foreach (var phone in testPhones)
{
Console.WriteLine("{0} bought a {1} {2} for {3:C}", phone.Owner, phone.Manufacturer, phone.Model, phone.Price);
}
Console.WriteLine();
// sorting the array by the size of the displays and then by the longest possible hours of talk
// and finally printing the result
var sorted = testPhones.OrderByDescending(x => x.Display.DisplaySize)
.ThenByDescending(y => y.Battery.HoursTalk);
foreach (var phone in sorted)
{
Console.WriteLine("{0} has display of {1}\" and can chat for {2} hours on his {3}"
, phone.Owner, phone.Display.DisplaySize, phone.Battery.HoursTalk, phone.Manufacturer);
}
// crating Iphone6 from Problem 6
var testIphone6 = GSM.IPhone_6;
// printign the full information for Iphone6
Console.WriteLine(GSM.FullPhoneInfo(testIphone6));
}