简体   繁体   English

寻呼机的页数

[英]count of pages for a pager

I have X number of items and I want to count how many pages I'll need to page these items if I can put 5 items per page. 我有X个项目,如果我每页可以放5个项目,我想要计算我需要多少页面来查看这些项目。

This is what I have: 这就是我所拥有的:

int TotalPages = (int)(Math.Ceiling(TheItemCount / 5));

The line is underlined in red with an error that's saying there's an 该行用红色加下划线,错误表示有一个错误

ambigious call between Math.Ceiling (double) and Math.Ceiling (decimal) Math.Ceiling(double)和Math.Ceiling(decimal)之间的暧昧调用

I know this is supposed to be simple but I'm not getting the result I want. 我知道这应该是简单的,但我没有得到我想要的结果。 What do I need to change in my code to make it work? 我需要在代码中进行哪些更改才能使其正常工作?

Thanks. 谢谢。

The issue is that the compiler can't figure out which overload you want, so just force it to use the one of them: 问题是编译器无法确定您想要的重载,因此只需强制它使用其中一个:

int TotalPages = (int)(Math.Ceiling((double)TheItemCount / 5.0));

another way would be this: 另一种方式是这样的:

int TotalPages = (int)(Math.Ceiling(Convert.ToDouble(TheItemCount / 5)));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM