I have three integer type variable
Suppose at initial level i have this
Totallistcount = 14;
perpagecount = 9;
Now I have a formula to found total number of pages possible
totalpagescount = Totallistcount / perpagecount ;
but in this situtation I got 1
in totalpagescount
but I need 2
in totalpagescount
, because 9 items on the first page and rest of item will be displayed on last page , How can I do this
Thanks ,
totalpagescount = (Totallistcount + perpagecount - 1) / perpagecount ;
This is how integer division should work, you need to convert it to double
first to be able to get the number and then use Ceiling
to "round it up":
(int)Math.Ceiling( (double)Totallistcount / perpagecount);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With