List 가변적인 크기를 가지는 배열이라고 생각하면 쉽게 이해가능
List<int> numbers = new List<int>(); numbers.add(0); //리스트에 데이터 추가 numbers.add(1); numbers.add(2); numbers.remove(0); //리스트에 데이터 제거
Dictionary 키와 값으로 구성된 데이터를 저장 (ex 이름+성적)
Dictionary<String, int> scores = new Dictionary<String, int>(); scores.add("김치", 80); //리스트에 데이터 추가 scores.add("치헌", 70); scores.add("김치헌", 90); scores.remove("김치헌"); //리스트에 데이터 제거 foreach(Keyvaluefair<Sting, int> pair in scores){ console.writeline(pair.key + ": "+pair.value);}
stack 후입선출
stack<int> stack1 = new stack<int>(); stack1.Push(0); //스택에 요소 추가 stack1.Pop(0); //스택에서 요소 가져오기
Queue 선입선출
Queue<int> Queue1 = new Queue<int>(); Queue1.Enqueue(0); //Queue에 요소 추가 Queue1.Dequeue(0); //Queue에서 요소 가져오기