代码有一处错误。请教
如下是Visual C#入门经典里128页的一个例子。我运行了有一个错误是“}expected”我觉得我的括号没有少啊。请问是怎么了呢?谢谢。using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace Ch07Ex01
{
class Program
{
static void Main(string[] args)
{
//创建源数据组
int[] testArray = { 4, 7, 4, 9, 7, 8, 3, 9, 1, 9 };
int[] maxValIndices;
int maxVal = MAXima(testArray, maxValIndices);
Console.WriteLine("Maxinum value is {0} found at element indices;", maxVal);
foreach (int index in maxValIndices)
{
Console.WriteLine(index);
}
static int Maxima(int[] integers,out int[] indices)
{
int maxVal=testArray[0];
int count=1;
int i;
for (i=1;i<testArray.length;i++)
{
if (testArray[i]>maxVal)
{
maxVal=testArray[i];
count=1;
indices=new int[1];
indices[0]=i;
}
else if(testArray[i]==maxVal)
{
count++;
int[] temp=indices;
indices=new int[count];
temp.CopyTo(indices,0);
indices[count-1]=i;
}
return maxVal;
}
}
}
}