Computer Language/유니티
가변 배열
알 수 없는 사용자
2014. 5. 16. 15:45
using UnityEngine;
using System.Collections;
public class chap10_6 : MonoBehaviour {
// Use this for initialization
void Start () {
/*
int[][] jagged = new int[3][];
jagged[0] = new int[5]{1, 2, 3, 4, 5} ;
jagged[1] = new int[5]{10,20,30} ;
jagged[2] = new int[5]{100,200} ;
*/
int[][] jagged2 = new int[2][] {
new int[]{1000, 2000} ,
new int[]{4, 5, 6, 7}
} ;
foreach(int[] arr in jagged2){
for(int i = 0; i < arr.GetLength(0); i++){
print(string.Format("arr[{0}] = {1}", i, arr[i]));
}
}
}
// Update is called once per frame
void Update () {
}
}