Computer Language/C#
[C#] 동적 배열 초기화
유민재
2021. 12. 19. 22:32
728x90
설명
정적배열 : 배열의 크기가 고정된 배열(ex. string[], int[,] 와 같이 (값 형식,참조 형식)에 [] 대괄호를 붙인다)
동적배열 : 배열의 크기가 변하는 배열
(ex. List, ArrayList, stack, queue, Dictionary, SortedList, ConcurrentBag..등등)
동적 배열 초기화 : = new 형식();
코드
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
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Concurrent;
namespace DynamicArray
{
class ArrayInfo
{
}
class Program
{
static void Main(string[] args)
{
List<int> intList = new List<int>();
ArrayList arrayList = new ArrayList();
Stack<string> stringStack = new Stack<string>();
Queue<object> objectQueue = new Queue<object>();
Dictionary<string, ArrayInfo> dictionary = new Dictionary<string, ArrayInfo>();
SortedDictionary<int, string> sortedDictionary = new SortedDictionary<int, string>();
ConcurrentBag<string> bag = new ConcurrentBag<string>();
}
}
}
|
cs |
반응형