LoginSignup
6
6

More than 5 years have passed since last update.

総ページ数の計算方法

Posted at

概要

Linqを使うと、あら不思議。

var pages = collection
   .Skip(itemsInPage)
   .Count()
;

ここで

  • pages: 総ページ数
  • collection: 全要素含むコレクション
  • itemsInPage: 1ページ内の要素数

説明(見たまんまだけど・・・)

Skip(itemsInPage)で各ページの先頭要素が取れるので、それを数え上げれば、ページ数っていう仕組み。

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6