通过函数交换数据(1)
namespace ConsoleApplication2
{
class Program
{
static int MaxValue(int[] intArray)
{
int maxVal = intArray[0];
for (int i = 1; i < intArray.Length; i++)
{
if(intArray [i]>maxVal)
maxVal=intArray [i];
}
return maxVal;
}
static void Main(string[] args)
{
int[] myArray = {1,3,8,9,5,6,0,2 };
int maxVal = MaxValue(myArray);
Console.WriteLine("The Maxlvaue in myArray is {0}", maxVal);
Console.ReadKey();
}
}
}