how to always round up to the next integer

leora picture leora · Jan 31, 2011 · Viewed 152.6k times · Source

i am trying to find total pages in building a pager on a website (so i want the result to be an integer. i get a list of records and i want to split into 10 per page (the page count)

when i do this:

list.Count() / 10

or

list.Count() / (decimal)10

and the list.Count() =12, i get a result of 1.

How would I code it so i get 2 in this case (the remainder should always add 1)

Answer

Rob picture Rob · Jan 31, 2011
Math.Ceiling((double)list.Count() / 10);