這是我在一些基本的C#編程中的嘗試。該程序旨在向用戶詢問數組的大小,然後填充數組,打印數組並最終找到它們用於填充數組的平均數。該程序目前不編譯。這是我第一次在沒有任何參考書的情況下做這個,所以有人可以幫我解釋我錯過了什麼嗎?謝謝。編輯:所有的程序工作除了有關在數組中找到平均值的部分。另外,如果有任何不適合生產級編碼的愚蠢錯誤,請告訴我。查找用戶指定大小的數組的平均值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;
}
}
您使用的是什麼版本的.Net框架? –
使用Visual Studio 2010 4.0 – wootscootinboogie