这是我对一些基本 C# 编程的尝试。该程序旨在询问用户数组的大小,然后填充数组,打印出数组,最后找到他们用来填充数组的数字的平均值。该程序当前无法编译。这是我第一次在没有任何参考书的情况下这样做,所以有人可以帮我解释一下我错过了什么吗?谢谢。编辑:所有程序都可以工作,除了关于查找数组中数字的平均值的部分。此外,如果有任何对于生产级编码不谨慎的愚蠢错误,请告诉我。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _9_21_Test
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("enter the amount of numbers you would like to find the average of: ");
int arraylength = Int32.Parse(Console.ReadLine());
int[] AverageArray = new int[arraylength];
//filling the array with user input
for (int i = 0; i < AverageArray.Length; i++)
{
Console.Write("enter the numbers you wish to find the average for: ");
AverageArray[i] = Int32.Parse(Console.ReadLine());
}
//printing out the array
Console.WriteLine("here is your array: ");
for(int i=0; i < AverageArray.Length; i++)
{
Console.WriteLine(AverageArray[i]);
}
Console.WriteLine(FindAverage);
}
}
//Method to find the average is another class for learning porpoises
class Calcs
{
public static double FindAverage(int[] averageNumbers);
int arraySum=0;
for(int i =0; i < averageNumbers.Length; int i++)
arraysum+=arraysum;
return double average = arraysum/averageNumbers.Length;
}
}