当前位置:网站首页>C list data paging

C list data paging

2022-04-23 21:25:00 Plant a sweet smell

c# List Data paging

#### List Paging 
    #region List Paging 
    /// <summary>
    /// List Paging 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="_list"></param>
    /// <param name="PageIndex"></param>
    /// <param name="PageSize"></param>
    /// <returns></returns>
    public static List<T> SplitList<T>(List<T> _list, int PageIndex, int PageSize)
    {
        int _PageIndex = PageIndex == 0 ? 1 : PageIndex;
        int _PageSize = PageSize == 0 ? 20 : PageSize;
        int PageConut = (int)Math.Ceiling(Convert.ToDecimal(_list.Count) / _PageSize);
        if (PageConut >= _PageIndex)
        {
            List<T> list = new List<T>();
            list = _list.Skip((_PageIndex - 1) * _PageSize).Take(_PageSize).ToList();
            return list;
        }
        else
            return _list;
    } 
    #endregion

List Cyclic paging processing


	#region List Cyclic paging processing 
    /// <summary>
    /// List Paging 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="_list"></param>
    /// <param name="PageIndex"></param>
    /// <param name="PageSize"></param>
    /// <returns></returns>
    public static void SplitList<T>(List<T> _list, int PageIndex, int PageSize)
    {
        int _PageIndex = PageIndex == 0 ? 1 : PageIndex;
        int _PageSize = PageSize == 0 ? 20 : PageSize;
        int PageConut = (int)Math.Ceiling(Convert.ToDecimal(_list.Count) / _PageSize);
        if (PageConut >= _PageIndex)
        {
        	for(int i=0,i<PageConut,i++)
            List<T> list = new List<T>();
            list = _list.Skip(PageConut * _PageSize).Take(_PageSize).ToList();
            //your code list 
        }
        else
            {
            	//your code _list
            }
    } 
    #endregion

May people sleep , One after another dreamed of stars that would never fall to the ground ; May people get drunk , One after another, they think of the poems they read when they were young !!!

版权声明
本文为[Plant a sweet smell]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/110/202204200619557083.html