title: Paging Huge Data With C# Web API Without Using Any Library
body: <p>I'm working on an API in C#. In one of our reports we need to send a huge data to the client. I did a lot of searching in libraries to provide pagination, and finally came up with the idea to write the function by myself.
  I have written this code and it works according to my needs:</p>
  <pre><code>public class PagedList&lt;T&gt;
          {
              public PagedList() { Data = new List&lt;T&gt;(); }
              public List&lt;T&gt; Data { get; set; }
              public List&lt;T&gt; ToPagedList(List&lt;T&gt; req, int PageNumber, int PageSize)
              {
                  var result = new List&lt;T&gt;();
                  var count = req.Count();
                  if (PageNumber * PageSize &gt; count &amp;&amp; count - PageNumber * PageSize &gt; PageSize)
                  {
                      PageNumber = count / PageSize;
                  }
                  for (int i = PageSize * (PageNumber - 1); i &lt;= PageSize * PageNumber - 1 &amp;&amp; i &lt; count; i++)
                      result.Add(req[i]);
                  return result;
              }
          }
  </code></pre>
  <p>The method will be used like following sample:</p>
  <pre><code>result = new MyClass.PagedList&lt;TransactionHistory&gt;().ToPagedList(result, PageNumber, PageSize);
  </code></pre>
  <p>The answer I got is too simple and I feel there is something wrong. Could I have made a mistake in this choice?</p>