Quantcast
Channel: C#タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9749

C#:2次元配列の解説

$
0
0

スクリーンショット 2020-03-23 9.51.49.png

Sample.cs
usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;// 2次元配列// * Table/表publicclassSample:MonoBehaviour{// 宣言方法// 1次元配列int[]arrayInt=newint[3];// 2次元配列int[,]tabelInt=newint[3,2];voidStart(){// 代入方法tabelInt[0,0]=1;tabelInt[2,1]=10;// 取得方法//int x = tabelInt[0, 0];//長さ//Debug.Log(arrayInt.Length);Debug.Log(tabelInt.GetLength(0));Debug.Log(tabelInt.GetLength(1));for(intx=0;x<tabelInt.GetLength(0);x++){for(inty=0;y<tabelInt.GetLength(1);y++){Debug.Log(tabelInt[x,y]);}}for(inty=0;y<tabelInt.GetLength(1);y++){for(intx=0;x<tabelInt.GetLength(0);x++){Debug.Log(tabelInt[x,y]);}}}}

Viewing all articles
Browse latest Browse all 9749

Trending Articles