I am working on this project with arrays. My code is below. My question is how do I get the two different arrays to print underneath the proper columns? I know this is probably a basic question but I am new to programming and we have not covered the Windows.Forms much.
Right now all the numbers are going under Array1.
I need it to look like:
Array1 Array2 Array3
1 22
2 32
3 14
4 54
5 23
6 71
7 234
8 63
9 91
10 11

Here is what I have:

static void Main()
        {
            double[] array1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

            double[] array2 = { 22, 32, 14, 54, 23, 71, 234, 63, 91, 11 };
            string outPut = "";
            string outPut2 = "";
            string caption = "Parallel Array Multiplier";

            //Display array1
            outPut += "Array1 * Array2 = Array3\n\n";
            outPut += "Array1\t Array2\t Array3\n";
 
            foreach (double aVal in array1)
                outPut += aVal + "\n";
            foreach (double aVal in array2)
                outPut2 += aVal + "\n";
            
            MessageBox.Show(outPut + outPut2, caption);
            
        }// End of Main

Thanks for any help

This way if you have an integer array (ar any other then string array):

int[] array = { 1, 2, 3, 4, 5 };
MessageBox.Show(String.Join("\n", array.Select(s => s.ToString()).ToArray()));
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.