c# - 无法将类型int隐式转换为int数组

我有简单的方法。我不知道为什么会引发错误。提前致谢!

 public static int[] Shift(int[] a) 
 {    
       if (a == null) return -1;
       ...
 }

编译器将引发以下错误:

Cannot implicitly convert type int to int[]

最佳答案

如果数组为null,则返回一个int。该函数期望一个int []。您可以返回null或空白数组。

https://stackoverflow.com/questions/42769644/

相关文章:

c++ - 编译器错误: not declared in the scope

c++ - 编译器在声明类时显示未定义的结构错误

.net - 使用xmlrpc和vb.net在wordpress中发布错误

c - 使用指针的程序运行不正常

python - mysql-python的pip安装错误无法正常工作

delphi - delphi编译错误 "[DCC Error] ProjectName.dpr([

c++ - 我的程序未发现struct中的功能

c++ - 为什么 “std::isdigit”在Windows上的C++中报告 “no match

java - “Cannot find symbol class keyboard reader”

c++ - LNK2019未解析的外部符号。创建二叉树