【发布时间】:2017-12-22 18:13:30
【问题描述】:
好的,我只需要确保我的编码正确。有时间请查看以下内容:
int [] Counter_Event = new int [46];
for (int xCount = 0; xCount < Counter_Event.Length; xCount++)
{ Counter_Event[xCount] = Math.Round(xCount * 10000);}
使用上述内容,它会抛出一个编译错误。我可能没有使用正确的语法,但任何观点都会有所帮助。
【问题讨论】:
-
编译错误消息可能包含一些关于您的语法不正确的信息。
-
如果您包含编译错误会有所帮助。我在运行您的代码时遇到的错误是 Math.Round,
CS0121 The call is ambiguous between the following methods or properties: 'Math.Round(double)' and 'Math.Round(decimal)' -
如果
xCount是一个int 而10000 是一个int,为什么需要Math.Round?它们已经是整数了…… -
语法错误 - 这不是 books 和 MSDN 的用途吗?
-
@Plutonix 确实如此。甚至语法错误的工具提示也准确地解释了问题所在。