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


C# System.Collections.Generic.List.OrderBy方法代码示例

本文整理汇总了C#中System.Collections.Generic.List.OrderBy方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.List.OrderBy方法的具体用法?C# System.Collections.Generic.List.OrderBy怎么用?C# System.Collections.Generic.List.OrderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.Generic.List的用法示例。


在下文中一共展示了System.Collections.Generic.List.OrderBy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestGetEnumerator

        public void TestGetEnumerator()
        {
            var hashSet = new HashSet<int>();
            Assert.IsTrue(hashSet.Add(1));
            Assert.IsTrue(hashSet.Add(2));
            Assert.IsTrue(hashSet.Add(3));
            Assert.IsTrue(hashSet.Add(4));

            var collection = new System.Collections.Generic.List<int>();

            foreach (var item in hashSet.Keys)
            {
                collection.Add(item);
            }

            Assert.AreEqual(collection.Count, hashSet.Keys.Count());
            CollectionAssert.AreEqual(collection.OrderBy(a => a).ToList(), hashSet.Keys.OrderBy(a => a).ToList());
        }
开发者ID:jesconsa,项目名称:Telerik-Academy,代码行数:18,代码来源:HashSetTest.cs

示例2: RefreshStatus

        void RefreshStatus()
        {
            System.Collections.IList projects;
            try {
                projects = (System.Collections.IList) CallApi ("/projects");
            }
            catch(Exception e)
            {
                Console.Error.WriteLine (e);
                ScheduleRefresh ();
                return;
            }

            int numberOfProjects = projects.Count;

            System.Collections.Generic.IList<System.Collections.IDictionary> projectsList = new System.Collections.Generic.List<System.Collections.IDictionary> ();
            foreach(System.Collections.IDictionary project in projects)
            {
                projectsList.Add (project);
            }

            projectsList = projectsList.OrderBy(x=>x["reponame"]).ToList();
            projectsList.Reverse ();

            foreach (Gtk.ImageMenuItem oldMenuItem in projectMenuItems) {
                menu.Remove (oldMenuItem);
            }
            projectMenuItems.Clear ();
            bool allGreen = true;
            foreach(System.Collections.IDictionary project in projects)
            {
                String statusString = null;
                System.Collections.IDictionary branches = (System.Collections.IDictionary) project["branches"];
                if (branches != null) {
                    System.Collections.IDictionary develop = (System.Collections.IDictionary) branches["develop"];
                    if (develop != null) {
                        System.Collections.IList recent_builds = (System.Collections.IList) develop ["recent_builds"];
                        if (recent_builds != null && recent_builds.Count > 0) {
                            System.Collections.IDictionary last_build = (System.Collections.IDictionary) recent_builds[0];
                            String status = (String) last_build ["status"];

                            if ("success".Equals (status)) {
                                statusString = "✓";
                            }
                            else if ("failed".Equals (status)) {
                                statusString = "✗";
                                allGreen = false;
                            }
                        }
                    }
                }

                if (statusString != null) {
                    String projectName = (String) project["reponame"];
                    // https://circleci.com/gh/transcovo/API-Node/tree/develop
                    String projectUrl = "https://circleci.com/gh/" +
                                        ((String)project ["username"]) + "/" +
                                        projectName + "/tree/develop";

                    ImageMenuItem newMenuItem = new Gtk.ImageMenuItem (statusString + " " + projectName);

                    newMenuItem.Activated += (object sender, EventArgs e) => System.Diagnostics.Process.Start (projectUrl);
                    projectMenuItems.Add (newMenuItem);
                    menu.Insert(newMenuItem, 0);
                }
            }
            menu.ShowAll ();
            if (allGreen) {
                indicator.IconName = greenFilePath;
            } else {
                indicator.IconName = redFilePath;
            }
            ScheduleRefresh ();
        }
开发者ID:rossille,项目名称:circleci-notification,代码行数:74,代码来源:CircleCiNotification.cs

示例3: ContrastShipPlan

    private void ContrastShipPlan(int version1, int version2, string[] flowArr, string item)
    {
        var mstrs1 = TheGenericMgr.FindAllWithCustomQuery<ShipPlanMstr>("select m from ShipPlanMstr as m where m.ReleaseNo=?", version1);
        var mstrs2 = TheGenericMgr.FindAllWithCustomQuery<ShipPlanMstr>("select m from ShipPlanMstr as m where m.ReleaseNo=?", version2);
        if (mstrs1 == null || mstrs1.Count == 0)
        {
            this.Resultlist.InnerHtml = "";
            ShowErrorMessage(string.Format("版本号{0}不存在,请确认。", version1));
            return;
        }
        if (mstrs2 == null || mstrs2.Count == 0)
        {
            this.Resultlist.InnerHtml = "";
            ShowErrorMessage(string.Format("版本号{0}不存在,请确认。", version2));
            return;
        }

        string searchHql = " select d from  ShipPlanDet as d where Type='Daily' ";
        if (!string.IsNullOrEmpty(item))
        {
            searchHql += string.Format(" and d.Item='{0}' ", item);
        }
        string flowstr = string.Empty;
        if (flowArr.Length > 0)
        {
            foreach (var flow in flowArr)
            {
                if (string.IsNullOrEmpty(flowstr))
                {
                    flowstr = string.Format(" and ( d.Flow='{0}' ", flow);
                }
                else {
                    flowstr += string.Format(" or d.Flow='{0}' ",flow);
                }
            }
            searchHql +=flowstr+")";
        }

        var dets1 = TheGenericMgr.FindAllWithCustomQuery<ShipPlanDet>(searchHql + " and d.ShipPlanId= " + mstrs1.First().Id);
        var dets2 = TheGenericMgr.FindAllWithCustomQuery<ShipPlanDet>(searchHql + " and d.ShipPlanId= " + mstrs2.First().Id);
        var minStartTime1 = dets1.Min(s => s.StartTime);
        dets1 = (from d in dets1
                 where  d.StartTime < minStartTime1.AddDays(14)
                 select d).ToList();

        var minStartTime2 = dets2.Min(s => s.StartTime);
        dets2 = (from d in dets2
                 where  d.StartTime < minStartTime2.AddDays(14)
                 select d).ToList();

        var allResult1 = new System.Collections.Generic.List<ShipPlanDet>();
        allResult1.AddRange(dets1);
        allResult1.AddRange(dets2);

        var planByFlowItems = allResult1.OrderBy(p => p.Flow).GroupBy(p => new { p.Flow, p.Item });

        var sTime = minStartTime1 < minStartTime2 ? minStartTime1 : minStartTime2;

        var eTime = minStartTime1 < minStartTime2 ? minStartTime2 : minStartTime1;

        StringBuilder str = new StringBuilder();
        str.Append("<table id='tt' runat='server' border='1' class='GV' style='width:150%;border-collapse:collapse;'>");
        str.Append("<thead><tr class='GVHeader'><th rowspan='2'>序号</th><th rowspan='2'>路线</th><th rowspan='2'>物料号</th><th rowspan='2'>物料描述</th><th rowspan='2'>客户零件号</th>");

        if (sTime.AddDays(14) <= eTime)
        {
            for (int i = 0; i < 14; i++)
            {
                str.Append("<th colspan='2'>");
                str.Append(sTime.ToString("yyyy-MM-dd"));
                str.Append("</th>");
                sTime = sTime.AddDays(1);
            }
            for (int i = 0; i < 14; i++)
            {
                str.Append("<th colspan='2'>");
                str.Append(eTime.ToString("yyyy-MM-dd"));
                str.Append("</th>");
                eTime = eTime.AddDays(1);
            }
            str.Append("</tr><tr class='GVHeader'>");

            for (int i = 0; i < 28; i++)
            {
                str.Append(string.Format("<th >{0}</th><th >{1}</th>", version1, version2));
            }

        }
        else
        {
            while (sTime <= eTime.AddDays(14))
            {
                str.Append("<th colspan='2'>");
                str.Append(sTime.ToString("yyyy-MM-dd"));
                str.Append("</th>");
                sTime = sTime.AddDays(1);
            }

            str.Append("</tr><tr class='GVHeader'>");
            sTime = minStartTime1 < minStartTime2 ? minStartTime1 : minStartTime2;
//.........这里部分代码省略.........
开发者ID:Novthirteen,项目名称:yfkey-scms,代码行数:101,代码来源:Main.ascx.cs


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