方法参数out
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _05050515数组的多个值
{
class Program
{
static void Main(string[] args)
{
int[] array = { 1,3,5};
int Max = 0;
int Min = 0;
int Sum = 0;
int Avg = 0;
GetArrayMaxMinSumAvg(array, out Max, out Min, out Sum, out Avg);
Console.WriteLine("{0}\t {1}\t {2}\t {3}",Max ,Min ,Sum ,Avg);
}
public static void GetArrayMaxMinSumAvg( int [] array ,out int Max ,out int Min ,out int Sum ,out int Avg)
{
Max = array[0];
Min = array[0];
Sum = 0;
for (int i = 0; i < array.Length; i++)
{
if (array[i] > Max)
{
Max = array[i];
}
if (array[i] < Min)
{
Min = array[i];
}
Sum = Sum + array[i];
}
Avg = Sum / array.Length;
}
}
}