study

[C#] Chapter 11. Array (test)

yz 2022. 6. 2. 18:20

my code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MyFirstCSharp_01
{
    public partial class Chap11_Array_test : Form
    {
        public Chap11_Array_test()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            int[,] aArray2 = new int[2, 4] { { 1, 2, 3, 4 }, { 5, 6, 7, 8 } };
            int iArrayRowCount = aArray2.GetLength(0); //행
            int iArrayColumnCount = aArray2.GetLength(1); //열
            
            string sArrayList = string.Empty;

            for (int x = (iArrayRowCount - 1); x >= 0; x--)
            {
                for (int y = 0; y < iArrayColumnCount; y++)
                {
                    sArrayList += $"{aArray2[x, y]}, ";
                    
                }
                textBox1.Text += sArrayList + "\r\n";
                sArrayList = "";
            }


        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            int[,] aArray2 = new int[2, 4] { { 1, 2, 3, 4 }, { 5, 6, 7, 8 } };
            int iArrayRowCount = aArray2.GetLength(0); //행
            int iArrayColumnCount = aArray2.GetLength(1); //열
            string sArrayList = string.Empty;

            for (int x = 0; x < iArrayRowCount; x++)
            {
                for (int y = 0; y < iArrayColumnCount; y++)
                {
                    sArrayList += $"{aArray2[x, y]}, ";

                }
                textBox1.Text += sArrayList + "\r\n";
                sArrayList = "";
            }
        }
    }
}

 

LIST