> 출력
Console.WriteLine("")
>배열
.GetLength(0) 로 다차원 길이 알수 있음.
> 딕셔너리
선언
Dictionary<string, int> dic = new Dictionary<string, int>();
키로 있는지 찾기
dic.ContainsKey("")
밸류 있는지 찾기
dic.ContainsValue("")
추가
dic.Add("", 1)
순회
foreach(var item in dic ) // dic.Count로 for문도 가능
{
item.Value
item.Key
}
키 없애기
Remove(Key)
모두제거
Clear()
키 없을 경우만 추가
TryAdd(Key,Value)
TryGetValue(Key,Value)
List<int> keys = new List<int>(dict.Keys); 가능
>리스트
선언
List<int> list = new List<int>();
추가
list.Add()
거꾸로 만들기
List<T>.Reverse()
개수
list.Count
모두제거
list.Clear()
부분 뽑기 가능
lst.GetRange()
List<string> range = rivers.GetRange(1, 2);
제거
Remove(obejct element) 특정 요소를 리스트에서 제거 ( 객체 지정 )
RemoveAt(int index) 특정 위치의 요소를 리스트에서 제거 ( 인덱스 지정 )
들어있는지 확인
list.Contains(3)
중복 제거
list.Distinct().ToList()
문자열로 리스트 합치기
string line = string.Join(",", list.ToArray());
딕셔너리 키 리스트 만들기
List<int> keys = new List<int>(dict.Keys);
> 집합
선언
SortedSet<int> s1 = new SortedSet<int>(arr);
추가
s1.Add(3)
제거
s1.Remove(object)
들어있는지
Set.Contatins(item) == true
몇개인지
s1.Count
문자열 나누기
string phrase = "The quick brown fox jumps over the lazy dog.";
string[] words = phrase.Split(' ');
리스트로 문자열 만들기
string line = string.Join(",", list.ToArray());
큐
Queue<int> q = new Queue<int>();
q.Enqueue(120);
q.Enqueue(130);
q.Enqueue(150);
int next = q.Dequeue(); // 120
next = q.Dequeue(); // 130
queue.Count
우선 순위 큐
PriorityQueue<string,int> pq=new PriorityQueue<string,int>();
//내부 자료 string //우선 순위 기준 int
pq.Enqueue("환자1-감기", 5);
pq.Enqueue("환자2-타박상", 8);
pq.Enqueue("환자3-응급", 1);
pq.Enqueue("환자4-교통사고", 3);
pq.Enqueue("환자5-탈모", 10);
Console.WriteLine(pq.Dequeue()); // 우선순위대로 빠짐
public struct Item
{
public int index;
public int play;
};
포카의 IT 블로그