运行效果:

批注 2020-09-08 153648.png

    class Program
{
    
    public static void Chengji(int[] a,out int max,out int sum)     //参数声明max与sum变量
    {
        Console.WriteLine("请依次输入5个整数成绩");
        for (int i = 0; i < a.Length; i++)
        {
            Console.WriteLine($"第{i + 1}个:");
            //Console.WriteLine("第{0}个:",i+1);
            a[i] = Convert.ToInt32(Console.ReadLine());             //为5个元素依次赋值
        }
        max = 0;
        for (int i = 0; i < a.Length; i++)
        {
            if (a[i] > max)
            {
                max = a[i];                                        //求数组的最大值
            }
        }
        sum = 0;
        for (int i = 0; i < a.Length; i++)
        {
            sum = sum + a[i];                                    //求数组每个元素的和
        }

    }
    static void Main(string[] args)             //主函数
    {

        Chengji(new int[5],out int max,out int sum);
        Console.WriteLine($"\n最大值为{max}");
        Console.WriteLine($"总和为{sum}");

        Console.ReadKey();
    }
}