Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7415541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:19:22+00:00 2026-05-29T07:19:22+00:00

I’m not looking for specific code, rather, I’m looking for information and guidance. I

  • 0

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.

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.

    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" && 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" && 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);


        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:19:24+00:00Added an answer on May 29, 2026 at 7:19 am

    Your question is not entirely clear, but from what I understand, to declare an array in a method and pass to another method to be filled, you just need:

    public void MethodA()
    {
        string[] stringArray = new string[100];
    
        MethodB(stringArray);
    }
    
    public void MethodB(string[] stringArray)
    {
        // Fill the array
        stringArray[0] = "Hello";
    
        // ...
    }
    

    If, however, you wish to pass some variable reference to a method to then have that method create the array and fill it, you will want to use the ref keyword (as you have with standard variables) on an array variable. Like so:

    public void MethodA()
    {
        string[] stringArray;
    
        MethodB(ref stringArray);
    
        // Array is now created and filled
    }
    
    public void MethodB(ref string[] stringArray)
    {
        // Create the array
        stringArray = new string[100];
    
        // Fill the array
        stringArray[0] = "Hello";
    
        // ...
    }
    

    To do either of these two approaches with two arrays is the same, but with an added parameter. i.e.:

    public void MethodB(string[] array1, int[] array2) { }
    
    public void MethodB(ref string[] array1, ref int[] array2) { }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.