当前位置: 首页>>代码示例>>C#>>正文


C# GSM.OrderByDescending方法代码示例

本文整理汇总了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));
        }
开发者ID:tddold,项目名称:TelerikAcademyHomework,代码行数:40,代码来源:GSMTest.cs


注:本文中的GSM.OrderByDescending方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。