반응형
C#에서는 Map을 Dictionary라고 부르는데 생성하고 초기화 할 수가 있다
Dictionary<String, int> test = new Dictionary<string, int>
{
{"a", 1}, {"b", 2}, {"c", 3}
}
근데 배열을 초기화 하려니까
Dictionary<String, int[]> test = new Dictionary<string, int[]>
{
{"a", {1, 2}}, {"b", {2, 3}}, {"c", {3, 4}}
}
이것도 아니고
Dictionary<String, int[]> test = new Dictionary<string, int[]>
{
{"a", [1, 2]}, {"b", [2, 3]}, {"c", [3, 4]}
}
이것도 아니었다
정답은
Dictionary<String, int[]> test = new Dictionary<string, int[]>
{
{"a", new [] {1, 2}}, {"b", new [] {2, 3}}, {"c", new [] {3, 4}}
}
반응형
'백엔드 > C#' 카테고리의 다른 글
DataTable을 DataGridView에 DataBinding (0) | 2018.05.11 |
---|---|
Form을 하나만 열고 싶을 때 (0) | 2018.05.11 |
Mdi Form / Mdi Child Form (0) | 2018.05.10 |
Parent/Child DataGridView (0) | 2018.05.10 |
폼 위치 변경 (0) | 2018.05.08 |
댓글