2차원 배열
arr[row,column] 헷갈리지 말기
using System;
using System.Collections.Generic;
using System.Text;
namespace Study07
{
class App
{
//생성자
public App()
{
//2차원 배열
int[,] arr0 = new int[2, 3]; //1차원 3, 2차원 2
//row,columm
for (int i = 0; i < arr0.GetLength(0); i++)
{
for (int j = 0; j < arr0.GetLength(1); j++)
{
arr0[i, j] = 1;
}
}
PrintArr(arr0);
}
void PrintArr(int [,] arr)
{
for (int i = 0; i < arr.GetLength(0); i++)
{
for (int j = 0; j < arr.GetLength(1); j++)
{
Console.Write(arr[i, j]);
}
Console.WriteLine();
}
}
}
}
'C#' 카테고리의 다른 글
대리자 (0) | 2023.01.11 |
---|---|
프로퍼티(Property)/Hashtable/구조체/인터페이스/다형성/오버라이딩 (0) | 2023.01.10 |
List<T>를 이용한 인벤토리 만들기 (0) | 2023.01.10 |
인벤토리2 (0) | 2023.01.09 |
방향키 입력 받아 이동 (0) | 2023.01.09 |