지식 창고
컬렉션 & 제네릭 사용하기 본문
using System.Collections;
string[] colors = {"red", "blue", "green"};
// Array
Array.Sort(colors);
Array.Reverse(colors);
// Stack
Stack stack = new Stack();
stack.Push(100);
stackPop();
// Queue
Queue queue = new Queue();
queue.Enqueue(100);
queue.Dequeue();
// ArrayList
ArrayList list = new ArrayList();
list.Add(10);
list.Add(20);
list.RemoveAt(1);
list.Insert(0, 50);
// HashTable
Hashtable hashtable = new Hashtable();
hashtable[0] = "ABC";
tashtable["NickName"] = "RedPlus";
using System.Collections.Generic;
// Stack
Stack<int> stack = new Stack<int>();
stack.Push(100);
// List
List<int> numbers = new List<int>();
numbers.Add(10);
numbers.Add(20);
// Dictionary
Dictionary<int, string> todos = new Dictionary<int, string>();
todos.Add(1, "AAA");
todos.Add(2, "BBB");
foreach(var item in todos)
{
Console.WriteLine($"{Item.Key} - {item.Value}");
}
'프로그래밍 > C#' 카테고리의 다른 글
윈도우즈 서비스 프로그램 (0) | 2022.01.06 |
---|---|
C#에서 메모리에 로드된 이미지를 전달하거나 C++에서 C#으로 전달 받는 방법 (0) | 2022.01.05 |
Array (0) | 2021.11.02 |
데이터 형식 사용하기 (0) | 2021.11.02 |
event Action (0) | 2021.11.02 |
Comments