c#分页增加顺序编号方法代码

        public static List<TModel<T>> ConvertList<T>(int pg, int pagesize, List<T> list)
        {
            List<TModel<T>> models = new List<TModel<T>>();
            int n = 0;
            int x = pg * pagesize;
            if (list.Count < pagesize)
            {
                x = pg * pagesize - pagesize + list.Count;
            }
            for (int i = (pg - 1) * pagesize; i < x; i++)
            {
                TModel<T> model = new TModel<T>();
                int m = i + 1;
                model.keyid = m;
                model.propert = list[n];
                models.Add(model);
                n++;
            }
            return models;
        }

        public class TModel<T>
        {
            public int keyid { get; set; }
            public T propert { get; set; }
        }

 

上一篇:JS实现分页


下一篇:Mybatis基础学习笔记(七) -PageHelper分页助手