ソースコード
using System.Collections.Generic;
using System.Linq;
public static class IEnumerableExtensions
{
<summary>
</summary>
<param name="pageNumber"></param>
<param name="countPerPage"></param>
public static IEnumerable<T> Paging<T>(
this IEnumerable<T> self,
int pageNumber,
int countPerPage )
{
return self
.Skip( countPerPage * pageNumber )
.Take( countPerPage );
}
}
使い方
var array = new int[ 100 ];
for ( int i = 0; i < 100; i++ )
{
array[ i ] = i;
}
array.Paging( 0, 10 );
array.Paging( 5, 10 );
関連記事