【发布时间】:2013-03-04 00:26:39
【问题描述】:
我的 winforms app(c#) 中有一个函数 (function1),它返回一个数组
函数内部1
public array function1(string value)
{
string[] array = new string[12];
//assigning values to the array elements....
retrun array;
}
我这样称呼这个函数
string id="Some id";
string[] array2 = new string[12];
array2=this.function1(id);
但它给了我错误
无法将类型“System.Array”隐式转换为“string[]”。存在显式转换(您是否缺少演员表?)
请高手帮帮我!
【问题讨论】:
-
我什至无法理解它是怎么来的:错误 CS0246:找不到类型或命名空间名称“数组”。
-
函数返回的“数组”可以是任意数组;但是 array2 只能保存对字符串数组的引用。因此错误。将函数的返回类型改为字符串[]。