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


C# List.GetRange方法代码示例

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


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

示例1: Sel_Ext_ByCode


//.........这里部分代码省略.........
                    {
                        ObjOrder = obj.OrderByDescending(a => a.ID).ToList();
                    }
                    break;
                case "IDAlbum":
                    if (IsDesc == "False")
                    {
                        ObjOrder = obj.OrderBy(a => a.IDAlbum).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.IDAlbum).ToList();
                    }
                    break;
                case "IDLang":
                    if (IsDesc == "False")
                    {
                        ObjOrder = obj.OrderBy(a => a.IDLang).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.IDLang).ToList();
                    }
                    break;

                case "Status":
                    if (IsDesc == "False")
                    {
                        ObjOrder = obj.OrderBy(a => a.Status).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.Status).ToList();
                    }
                    break;
                case "Tag":
                    if (IsDesc == "False")
                    {
                        ObjOrder = obj.OrderBy(a => a.Tag).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.Tag).ToList();
                    }
                    break;
                case "Type":
                    if (IsDesc == "False")
                    {
                        ObjOrder = obj.OrderBy(a => a.Type).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.Type).ToList();
                    }
                    break;
                case "ViewCount":
                    if (IsDesc == "False")
                    {
                        ObjOrder = obj.OrderBy(a => a.ViewCount).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.ViewCount).ToList();
                    }
                    break;

                default:
                    ObjOrder = obj;
                    break;
            }

            for (int i = 0; i < ObjOrder.Count; i++)
            {
                if ((TitleLenght > -1) & (ObjOrder[i].CategoryNameLevel2.Length > TitleLenght))
                {
                    ObjOrder[i].CategoryNameLevel2 = ObjOrder[i].CategoryNameLevel2.Substring(0, TitleLenght - 1);
                }
                if ((IntroLenght > -1) & (ObjOrder[i].Info.Length > IntroLenght))
                {
                    ObjOrder[i].Info = ObjOrder[i].Info.Substring(0, IntroLenght - 1);
                }
            }
            List<vw_CategoryLevel2ViewAll> ObjOrderLimit = new List<vw_CategoryLevel2ViewAll>();
            if ((Limit > -1) & (ObjOrder.Count > Limit))
            {
                ObjOrderLimit = ObjOrder.GetRange(0, Limit).ToList();
                _converter.DateTimeFormat = "dd/MM/yyyy";
                jSonString = JsonConvert.SerializeObject(ObjOrderLimit, _converter);
            }
            else
            {
                if (ObjOrder != null)
                {
                    _converter.DateTimeFormat = "dd/MM/yyyy";
                    jSonString = JsonConvert.SerializeObject(ObjOrder, _converter);
                }
            }
            jSonString = "{\"CategoryLevel2\":" + jSonString + "}";
            context.Response.Write(jSonString);
        }
开发者ID:califaxit,项目名称:manhquang,代码行数:101,代码来源:CategoryLevel2Action.cs

示例2: Sel_ListCategoryLevel2_ByType_ByIDLang

        public void Sel_ListCategoryLevel2_ByType_ByIDLang(HttpContext context)
        {
            String jSonString = "";

            int Type = context.Request.QueryString["Type"] != null && context.Request.QueryString["Type"] != "undefined" ? int.Parse(context.Request.QueryString["Type"]) : -1;
            int IDLang = string.IsNullOrEmpty(context.Request.QueryString["IDLang"]) == false && context.Request.QueryString["IDLang"] != "undefined" ? int.Parse(context.Request.QueryString["IDLang"]) : 1;
            int IntroLenght = context.Request.QueryString["IntroLenght"] != null && context.Request.QueryString["IntroLenght"] != "undefined" ? int.Parse(context.Request.QueryString["IntroLenght"]) : -1;
            int TitleLenght = context.Request.QueryString["TitleLenght"] != null && context.Request.QueryString["TitleLenght"] != "undefined" ? int.Parse(context.Request.QueryString["TitleLenght"]) : -1;
            int Limit = context.Request.QueryString["Limit"] != null && context.Request.QueryString["Limit"] != "undefined" ? int.Parse(context.Request.QueryString["Limit"]) : -1;
            string Order = context.Request.QueryString["Order"] != null && context.Request.QueryString["Order"] != "undefined" ? context.Request.QueryString["Order"] : "-1";
            string IsDesc = context.Request.QueryString["IsDesc"] != null && context.Request.QueryString["IsDesc"] != "undefined" ? context.Request.QueryString["IsDesc"] : "-1";

            CategoryLevel2BO aCategoryLevel2BO = new CategoryLevel2BO();
            List<CategoryLevel2> obj = aCategoryLevel2BO.Sel_ByType_ByIDLang(Type, IDLang);
            List<CategoryLevel2> ObjOrder = new List<CategoryLevel2>();

            switch (Order)
            {
                case "Code":
                    if (IsDesc == "False")
                    {
                        ObjOrder = obj.OrderBy(a => a.Code).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.Code).ToList();
                    }
                    break;
                case "CategoryNameLevel2":
                    if (IsDesc == "False")
                    {
                        ObjOrder = obj.OrderBy(a => a.CategoryNameLevel2).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.CategoryNameLevel2).ToList();
                    }
                    break;

                case "ViewCount":
                    if (IsDesc == "False")
                    {
                        ObjOrder = obj.OrderBy(a => a.ViewCount).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.ViewCount).ToList();
                    }
                    break;

                default:
                    ObjOrder = obj;
                    break;
            }
            for (int i = 0; i < ObjOrder.Count; i++)
            {
                if ((TitleLenght > -1) & (ObjOrder[i].CategoryNameLevel2.Length > TitleLenght))
                {
                    ObjOrder[i].CategoryNameLevel2 = ObjOrder[i].CategoryNameLevel2.Substring(0, TitleLenght - 1);
                }

            }
            List<CategoryLevel2> ObjOrderLimit = new List<CategoryLevel2>();
            if ((Limit > -1) & (ObjOrder.Count > Limit))
            {
                ObjOrderLimit = ObjOrder.GetRange(0, Limit).ToList();
                _converter.DateTimeFormat = "dd/MM/yyyy";
                jSonString = JsonConvert.SerializeObject(ObjOrderLimit, _converter);
            }
            else
            {
                if (ObjOrder != null)
                {
                    _converter.DateTimeFormat = "dd/MM/yyyy";
                    jSonString = JsonConvert.SerializeObject(ObjOrder, _converter);
                }
            }
            jSonString = "{\"CategoryLevel2\":" + jSonString + "}";
            context.Response.Write(jSonString);
        }
开发者ID:califaxit,项目名称:manhquang,代码行数:80,代码来源:CategoryLevel2Action.cs

示例3: ConvertList


//.........这里部分代码省略.........
                    if (IsDesc == false)
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderBy(a => a.Image3).ToList();
                    }
                    else
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderByDescending(a => a.Image3).ToList();
                    }
                    break;
                //==============================================================================
                case "Tag":
                    if (IsDesc == false)
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderBy(a => a.Tag).ToList();
                    }
                    else
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderByDescending(a => a.Tag).ToList();
                    }
                    break;
                //==============================================================================
                case "Info":
                    if (IsDesc == false)
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderBy(a => a.Info).ToList();
                    }
                    else
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderByDescending(a => a.Info).ToList();
                    }
                    break;
                //==============================================================================
                case "Intro":
                    if (IsDesc == false)
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderBy(a => a.Intro).ToList();
                    }
                    else
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderByDescending(a => a.Intro).ToList();
                    }
                    break;

                //==============================================================================
                case "IDAlbum":
                    if (IsDesc == false)
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderBy(a => a.IDAlbum).ToList();
                    }
                    else
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderByDescending(a => a.IDAlbum).ToList();
                    }
                    break;

                //==============================================================================
                case "ViewCount":
                    if (IsDesc == false)
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderBy(a => a.ViewCount).ToList();
                    }
                    else
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderByDescending(a => a.ViewCount).ToList();
                    }
                    break;
                //==============================================================================
                default:

                    break;
            }
            //###############################################################################
            int InfoLenght_Tempt = InfoLenght;
            int IntroLenght_Tempt = IntroLenght;

            for (int i = 0; i < Limit; i++)
            {
                if (ListCategoryLevel2[i].Info.Length < InfoLenght)
                {
                    InfoLenght_Tempt = ListCategoryLevel2[i].Info.Length;
                }
                if (ListCategoryLevel2[i].Intro.Length < IntroLenght_Tempt)
                {
                    IntroLenght_Tempt = ListCategoryLevel2[i].Intro.Length;
                }

                //if (TitleLenght == 0) { TitleLenght = 1; }
                //if (IntroLenght == 0) { IntroLenght = 1; }

                ListCategoryLevel2[i].Info = ListCategoryLevel2[i].Info.Substring(0, InfoLenght_Tempt);
                ListCategoryLevel2[i].Intro = ListCategoryLevel2[i].Intro.Substring(0, IntroLenght_Tempt);

                InfoLenght_Tempt = InfoLenght;
                IntroLenght_Tempt = IntroLenght;
            }

            ListCategoryLevel2 = ListCategoryLevel2.GetRange(0, Limit).ToList();
            return ListCategoryLevel2;
            //=========================
        }
开发者ID:califaxit,项目名称:manhquang,代码行数:101,代码来源:CategoryLevel2Action.cs

示例4: Sel_Ext_ByCode


//.........这里部分代码省略.........
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.CategoryLevel2_Status).ToList();
                    }
                    break;
                case "CategoryLevel2_ID":
                    if (IsDesc == false)
                    {
                        ObjOrder = obj.OrderBy(a => a.CategoryLevel2_ID).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.CategoryLevel2_ID).ToList();
                    }
                    break;
                case "CategoryLevel1_ViewCount":
                    if (IsDesc == false)
                    {
                        ObjOrder = obj.OrderBy(a => a.CategoryLevel1_ViewCount).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.CategoryLevel1_ViewCount).ToList();
                    }
                    break;
                case "CategoryLevel1_Type":
                    if (IsDesc == false)
                    {
                        ObjOrder = obj.OrderBy(a => a.CategoryLevel1_Type).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.CategoryLevel1_Type).ToList();
                    }
                    break;
                case "CategoryLevel1_Status":
                    if (IsDesc == false)
                    {
                        ObjOrder = obj.OrderBy(a => a.CategoryLevel1_Status).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.CategoryLevel1_Status).ToList();
                    }
                    break;
                case "CategoryLevel1_ID":
                    if (IsDesc == false)
                    {
                        ObjOrder = obj.OrderBy(a => a.CategoryLevel1_ID).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.CategoryLevel1_ID).ToList();
                    }
                    break;
                case "CategoryLevel1_CategoryLevel2_Disable":
                    if (IsDesc == false)
                    {
                        ObjOrder = obj.OrderBy(a => a.CategoryLevel1_CategoryLevel2_Disable).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.CategoryLevel1_CategoryLevel2_Disable).ToList();
                    }
                    break;
                default:
                    ObjOrder = obj;
                    break;
            }

            for (int i = 0; i < ObjOrder.Count; i++)
            {
                if ((TitleLenght > -1) & (ObjOrder[i].CategoryLevel1_CategoryNameLevel1.Length > TitleLenght))
                {
                    ObjOrder[i].CategoryLevel1_CategoryNameLevel1 = ObjOrder[i].CategoryLevel1_CategoryNameLevel1.Substring(0, TitleLenght - 1);
                }
                if ((IntroLenght > -1) & (ObjOrder[i].CategoryLevel1_Info.Length > IntroLenght))
                {
                    ObjOrder[i].CategoryLevel1_Info = ObjOrder[i].CategoryLevel1_Info.Substring(0, IntroLenght - 1);
                }
            }
            List<vw_CategoryLevel1ViewAll> ObjOrderLimit = new List<vw_CategoryLevel1ViewAll>();
            if ((Limit > -1) & (ObjOrder.Count > Limit))
            {
                ObjOrderLimit = ObjOrder.GetRange(0, Limit).ToList();
                _converter.DateTimeFormat = "dd/MM/yyyy";
                jSonString = JsonConvert.SerializeObject(ObjOrderLimit, _converter);
            }
            else
            {
                if (ObjOrder != null)
                {
                    _converter.DateTimeFormat = "dd/MM/yyyy";
                    jSonString = JsonConvert.SerializeObject(ObjOrder, _converter);
                }
            }
            jSonString = "{\"CategoryLevel1\":" + jSonString + "}";
            context.Response.Write(jSonString);
        }
开发者ID:califaxit,项目名称:manhquang,代码行数:101,代码来源:CategoryLevel1Action.cs

示例5: Sel_Ext_ByCodeCategoryLevel2_ByIDLang

        // Load ra danh sách các CategoryLevel1 bằng CodeCategpryLevel2 va IDLang
        public void Sel_Ext_ByCodeCategoryLevel2_ByIDLang(HttpContext context)
        {
            String jSonString = "";
            bool Disable = !String.IsNullOrEmpty(context.Request.QueryString["Disable"])
               ? Convert.ToBoolean(context.Request.QueryString["Disable"])
               : false;
            string CodeCategoryLevel2 = context.Request.QueryString["CodeCategoryLevel2"] != null && context.Request.QueryString["CodeCategoryLevel2"] != "undefined" ? context.Request.QueryString["CodeCategoryLevel2"] : "-1";
            int TitleLenght = context.Request.QueryString["TitleLenght"] != null && context.Request.QueryString["TitleLenght"] != "undefined" ? int.Parse(context.Request.QueryString["TitleLenght"]) : 100;
            int Limit = context.Request.QueryString["Limit"] != null && context.Request.QueryString["Limit"] != "undefined" ? int.Parse(context.Request.QueryString["Limit"]) : 100;
            string Order = context.Request.QueryString["Order"] != null && context.Request.QueryString["Order"] != "undefined" ? context.Request.QueryString["Order"] : "CategoryLevel1_CategoryNameLevel1";
            string IsDesc = context.Request.QueryString["IsDesc"] != null && context.Request.QueryString["IsDesc"] != "undefined" ? context.Request.QueryString["IsDesc"] : "true";

            int IDLang = !string.IsNullOrEmpty(context.Request.QueryString["IDLang"]) ? int.Parse(context.Request.QueryString["IDLang"]) : 1;

            CategoryLevel1BO aCategoryLevel1BO = new CategoryLevel1BO();
            List<vw_CategoryLevel1ViewAll> obj = String.IsNullOrEmpty(context.Request.QueryString["Disable"]) ?
                aCategoryLevel1BO.Sel_Ext_ByCodeCategoryLevel2_ByIDLang(CodeCategoryLevel2, IDLang).ToList() :
                aCategoryLevel1BO.Sel_Ext_ByCodeCategoryLevel2_ByIDLang(CodeCategoryLevel2, IDLang, Disable).ToList();
            List<vw_CategoryLevel1ViewAll> ObjOrder = new List<vw_CategoryLevel1ViewAll>();

            switch (Order)
            {
                case "CategoryLevel1_CategoryNameLevel1":
                    if (IsDesc == "False")
                    {
                        ObjOrder = obj.OrderBy(a => a.CategoryLevel1_CategoryNameLevel1).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.CategoryLevel1_CategoryNameLevel1).ToList();
                    }
                    break;
                case "CategoryLevel2_CategoryNameLevel2":
                    if (IsDesc == "False")
                    {
                        ObjOrder = obj.OrderBy(a => a.CategoryLevel2_CategoryNameLevel2).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.CategoryLevel2_CategoryNameLevel2).ToList();
                    }
                    break;
                case "CategoryLevel1_ID":
                    if (IsDesc == "False")
                    {
                        ObjOrder = obj.OrderBy(a => a.CategoryLevel1_ID).ToList();
                    }
                    else
                    {
                        ObjOrder = obj.OrderByDescending(a => a.CategoryLevel1_ID).ToList();
                    }
                    break;
                default:
                    ObjOrder = obj;
                    break;
            }

            for (int i = 0; i < ObjOrder.Count; i++)
            {
                if ((TitleLenght > -1) & (ObjOrder[i].CategoryLevel1_CategoryNameLevel1.Length > TitleLenght))
                {
                    ObjOrder[i].CategoryLevel1_CategoryNameLevel1 = ObjOrder[i].CategoryLevel1_CategoryNameLevel1.Substring(0, TitleLenght - 1);
                }
            }
            List<vw_CategoryLevel1ViewAll> ObjOrderLimit = new List<vw_CategoryLevel1ViewAll>();
            if ((Limit > -1) & (ObjOrder.Count > Limit))
            {
                ObjOrderLimit = ObjOrder.GetRange(0, Limit).ToList();

                _converter.DateTimeFormat = "dd/MM/yyyy";
                jSonString = JsonConvert.SerializeObject(ObjOrderLimit, _converter);
            }
            else
            {
                if (ObjOrder != null)
                {
                    _converter.DateTimeFormat = "dd/MM/yyyy";
                    jSonString = JsonConvert.SerializeObject(ObjOrder, _converter);
                }
            }
            jSonString = "{\"data\":" + jSonString + "}";
            context.Response.Write(jSonString);
        }
开发者ID:califaxit,项目名称:manhquang,代码行数:84,代码来源:CategoryLevel1Action.cs

示例6: ConvertList


//.........这里部分代码省略.........
                        ListContent = ListContent.OrderBy(a => a.LikeCount).ToList();
                    }
                    else {
                        ListContent = ListContent.OrderByDescending(a => a.LikeCount).ToList();
                    }
                    break;
                //==============================================================================
                case "PublishDate":
                    if (IsDesc == false) {
                        ListContent = ListContent.OrderBy(a => a.PublishDate).ToList();
                    }
                    else {
                        ListContent = ListContent.OrderByDescending(a => a.PublishDate).ToList();
                    }
                    break;
                //==============================================================================
                case "ViewCount":
                    if (IsDesc == false) {
                        ListContent = ListContent.OrderBy(a => a.ViewCount).ToList();
                    }
                    else {
                        ListContent = ListContent.OrderByDescending(a => a.ViewCount).ToList();
                    }
                    break;
                //==============================================================================
                case "Vote":
                    if (IsDesc == false) {
                        ListContent = ListContent.OrderBy(a => a.Vote).ToList();
                    }
                    else {
                        ListContent = ListContent.OrderByDescending(a => a.Vote).ToList();
                    }
                    break;
                //==============================================================================
                case "Type":
                    if (IsDesc == false) {
                        ListContent = ListContent.OrderBy(a => a.Type).ToList();
                    }
                    else {
                        ListContent = ListContent.OrderByDescending(a => a.Type).ToList();
                    }
                    break;
                //==============================================================================
                case "Title":
                    if (IsDesc == false) {
                        ListContent = ListContent.OrderBy(a => a.Title).ToList();
                    }
                    else {
                        ListContent = ListContent.OrderByDescending(a => a.Title).ToList();
                    }
                    break;
                //==============================================================================
                case "Status":
                    if (IsDesc == false) {
                        ListContent = ListContent.OrderBy(a => a.Status).ToList();
                    }
                    else {
                        ListContent = ListContent.OrderByDescending(a => a.Status).ToList();
                    }
                    break;
                //==============================================================================
                case "Disable":
                    if (IsDesc == false) {
                        ListContent = ListContent.OrderBy(a => a.Disable).ToList();
                    }
                    else {
                        ListContent = ListContent.OrderByDescending(a => a.Disable).ToList();
                    }
                    break;
                //==============================================================================
                default:

                    break;
            }
            //###############################################################################
            int TitleLenght_Tempt = TitleLenght;
            int IntroLenght_Tempt = IntroLenght;

            for (int i = 0; i < Limit; i++) {
                if (ListContent[i].Title.Length < TitleLenght_Tempt) {
                    TitleLenght_Tempt = ListContent[i].Title.Length;
                }
                if (ListContent[i].Intro.Length < IntroLenght_Tempt) {
                    IntroLenght_Tempt = ListContent[i].Intro.Length;
                }

                //if (TitleLenght == 0) { TitleLenght = 1; }
                //if (IntroLenght == 0) { IntroLenght = 1; }

                ListContent[i].Title = ListContent[i].Title.Substring(0, TitleLenght_Tempt);
                ListContent[i].Intro = ListContent[i].Intro.Substring(0, IntroLenght_Tempt);

                TitleLenght_Tempt = TitleLenght;
                IntroLenght_Tempt = IntroLenght;
            }

            ListContent = ListContent.GetRange(0, Limit).ToList();
            return ListContent;
            //=========================
        }
开发者ID:califaxit,项目名称:manhquang,代码行数:101,代码来源:ContentsAction.cs


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