【发布时间】:2017-03-13 17:20:40
【问题描述】:
我有简单的方法。我无法弄清楚为什么它会引发错误。提前致谢!
public static int[] Shift(int[] a)
{
if (a == null) return -1;
...
}
编译器抛出以下错误:
无法将类型
int隐式转换为int[]
【问题讨论】:
-
值 -1 不是 int 数组,因此不能作为 int 数组返回。
-
如何返回 int 数组?我刚开始学习 C# 教程..
-
如果 a== null 是错误条件,您可以抛出异常或返回 null
-
更改方法签名以返回'int`
-
对于它的价值,如果你刚刚开始,有一篇关于调试的非常好的文章here。
标签: c# arrays methods compiler-errors int