//顺序
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 List<TModel<T>> ResvertList<T>(int pg, int pagesize, List<T> list, int pagenum)
{
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 c = pagenum - i;
model.keyid = c;
model.propert = list[n];
models.Add(model);
n++;
}
return models;
}
public class TModel<T>
{
public int keyid { get; set; }
public T propert { get; set; }
}