求各位指点这段调用函数的代码哪错了
namespace ConsoleApplication8{
class program
{
static int MaxValue(int[] intArray, out int maxIndex)
{
int maxVal = intArray[0];
maxIndex = 0;
for (int i = 1; i < intArray.Length; i++)
{
if (intArray[i] > maxVal)
{
maxVal = intArray[i];
maxIndex = i;
}
return maxVal;
}
}
static void Main(string[] args)
{
int[] myArray = { 1, 8, 3, 6, 2, 5, 9, 3, 0, 2 };
int maxIndex;
Console.WriteLine("The maximum value in myArray is {0}",MaxValue(myArray,out maxIndex));
Console.WriteLine("The first occurrence of this value is at element {0}", maxIndex + 1);
}
//I dont know where the problems lies.
}
}
-------------------------------------------------------------------------------------------------------------
功能是找出最大值。
报错窗口
not all code paths return a value.
感激不尽!