I have been working on this all day can someone please tell me what I am doing wrong.

using System;
public class ArrayManagement
{
    public static void Main(string[] args)
    {
        int[] myArray;
        myArray = new int[7];
        myArray = fillArray();
        int sum, avg;
        arrayMath(myArray, out sum, out avg);
        displayArray(myArray);
    }
    public static void arrayMath(int[] myArray, out int sum, out int avg)
    {
        sum = myArray.Sum();
        avg = myArray.Average();
    }
   public static void displayArray(int[] myArray)
    {
        Console.Write("Your sum and average is: ");
        for (int i = 0; i < 8; i++)
            Console.Write(myArray[i] + " ");
        Console.WriteLine();

    }
   public static int[] fillArray()
    {
        int[] myArray;
        myArray = new int[7];
        int count = 0;
        do
        {
            Console.Write("Please enter a number to add to the array or \"x\" to stop: ");
            string consoleInput = Console.ReadLine();
            if (consoleInput == "x")
            {
                return myArray;
            }
            else
            {
                myArray[count] = Convert.ToInt32(consoleInput);
                ++count;
            }

        } while (count < 8);
       return myArray;
        }
    }

Edited 3 Years Ago by Dani: Formatting fixed

If we knew what your were trying to achieve and what you are having problems with, we might be more inclined to help.
Also, put your code between [ CODE ] tags

Edited 4 Years Ago by dwarvenassassin: n/a

I made just enough adjustments to make it compile and run without crashing.
There are some design adjustments you will need to make:

using System;
using System.Linq;

public class ArrayManagement
{
   public static void Main(string[] args)
   {
      int[] myArray;
      myArray = new int[7];
      myArray = fillArray();
      int sum, avg;
      arrayMath(myArray, out sum, out avg);
      displayArray(myArray);
   }

   public static void arrayMath(int[] myArray, out int sum, out int avg)
   {
      sum = myArray.Sum();
      avg = (int)myArray.Average();
   }
   public static void displayArray(int[] myArray)
   {
      Console.Write("Your sum and average is: ");
      for (int i = 0; i < myArray.Count(); i++)
         Console.Write(myArray[i] + " ");
      Console.WriteLine();

   }
   public static int[] fillArray()
   {
      int[] myArray;
      myArray = new int[7];
      int count = 0;
      do
      {
         Console.Write("Please enter a number to add to the array or \"x\" to stop: ");
         string consoleInput = Console.ReadLine();
         if (consoleInput == "x")
         {
            return myArray;
         }
         else
         {
            myArray[count] = Convert.ToInt32(consoleInput);
            ++count;
         }

      } while (count < 8);
      return myArray;
   }
}
This article has been dead for over six months. Start a new discussion instead.