728x90
List
list를 쓰기 위해서는 using System.Collections.Generic 을 해줘야 한다.
리스트는 배열처럼 딱 할당 받아서 쓰는 것이아니라 하나하나를 추가해주면서 메모리를 받는다.
그래서 배열보다 사용하기 편하다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace List { class Program { static void Main(string[] args) { List<int> list_int = new List<int>(); //System.Collections.Generic list_int.Add(1); list_int.Add(2); list_int.Insert(1, 5); for (int i = 0; i < list_int.Count; i++) { Console.WriteLine(list_int[i]); } Console.WriteLine("-----------------------------------------------------------------------------"); list_int.RemoveAt(1); for (int i = 0; i < list_int.Count; i++) { Console.WriteLine(list_int[i]); } } } } | cs |
주의 할점은 중간 데이터를 삭제할때 인덱스가 바뀐다는 점이다.
'언어 > Unity' 카테고리의 다른 글
[Unity] GUI 만들기 (0) | 2018.01.29 |
---|---|
[Unity}Nullable (0) | 2018.01.25 |
[Unity]대리자를 이용한 콜백함수 만들기 (958) | 2018.01.22 |
[Unity]대리자 delegate (20) | 2018.01.20 |
[Unity]Split함수로 문자열 자르기 (0) | 2018.01.19 |