Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing two arrays from one method to gather user info from another method C#
    text
    copied!<p>I'm not looking for specific code, rather, I'm looking for information and guidance. I want to learn but don't really want someone to code it.</p> <p>I am looking in how to pass two arrays to a different method so they can be filled with user input. I can't seem to figure this out and I have researched various sites as well as my text and lectures and can't find the required techniques to do this. I know how to pass one array to a different method for processing (IE getting avg/sum etcetc) but not how to fill two arrays from one seperate method. Any guidance and information would be greatly appreciated. This is what I've got so far, or rather, what I'm left with. I got the other methods fairly done over, just need this part to move onto the debugging phase.</p> <pre><code> using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace PhoneDial { class Program { // Get player names and their scores and stores them into array for an unknown number of players up to 100 static void InputData(string[] nameList, int[]playerScore) { string userInput; int count = 0; do { Console.Write("\nEnter a players name: "); userInput = Console.ReadLine(); if (userInput != "Q" &amp;&amp; userInput != "q") { nameList[0] = Console.ReadLine(); ++count; } else break; Console.WriteLine("Enter {0}'s score:", userInput); playerScore[0] = Convert.ToInt32(Console.ReadLine()); } while (userInput != "Q" &amp;&amp; userInput != "q"); } //Declare variables for number of players and average score and two arrays of size 100 (one for names, one for respective scores //Calls functions in sequence, passing necessary parameters by reference //InputData(), passing arrays and number of players variable by reference //DisplayPlayerData(), passing arrays and number of players by reference //CalculateAverageScore(), passing arrays and number of players by reference. Store returned value in avg variable //DisplayBelowAverage(), passing arrays and number of players variable by reference, passing average variable by value static void Main(string[] args) { string[] nameList = new string[100]; int[] playerScore = new int[100]; int count = 0, avg = 0; InputData(nameList, playerScore); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload