반응형
250x250
Notice
Recent Posts
Recent Comments
Link
«   2025/04   »
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 26
27 28 29 30
Archives
Today
Total
관리 메뉴

폴크(FOLC)

C# - 데이터 초기화 방법 본문

C#, WF, WPF(.NET)

C# - 데이터 초기화 방법

folcjin 2025. 4. 10. 18:37
728x90
반응형

int x = 0;

bool b = false;

string s = null;

MyClass obj = null

int[] arr = null;     // null (배열은 참조형)
int[] numbers = new int[5];      // {0, 0, 0, 0, 0}

byte[] arr = null;     // null (배열은 참조형)
byte[] numbers = new byte[0];
byte[] numbers = Array.Empty<byte>();

float[] arr = null;     // null (배열은 참조형)
float [] numbers = new float[0];
float [] numbers = Array.Empty< float>();

string[] names = new string[3]; // {null, null, null}
string[] fruits = { "apple", "banana", "cherry" };

int[,] grid = new int[2, 3]; // 2행 3열, 기본값은 0
int[,] matrix = { { 1, 2 }, { 3, 4 } };

List<int> list = new List<int> { 1, 2, 3 };
int[] arr = list.ToArray();

728x90
반응형
사업자 정보 표시
사업자 등록번호 : -- | TEL : --

'C#, WF, WPF(.NET)' 카테고리의 다른 글

.NET 6  (0) 2022.01.22