ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[¤À¨É] C# ¦hºû°}¦C

[¤À¨É] C# ¦hºû°}¦C

.Net Framework¤w¤º«Ø³\¦h±j¤jªº¸ê®Æµ²ºcª«¥ó¡A
­ì¥Í°}¦C»yªk¨Ï¥Î¨ìªº¾÷·|¨Ã¤£°ª¡A¤£¹L¥¦ÁÙ¬OÆZ­«­nªº¡C

¦hºû°}¦C¤À¬°³W«h»P¤£³W«h¨âºØ¡C
³W«h°}¦Cªº«Å§i¤è¦¡¬O
int [ , ] array = new int[3, 3]; // ¤@­Ó3x3ªº¤Gºû°}¦C

¦b«Å§iªº®É­Ô¥i¥H¶¶«Kªì©l¤Æ
int [ , ] array = new int[3, 3] { {1,2,3}, {4, 5, 6}, {7,8,9} };
¤]¥i¥H¤£«Å§iºû«×¡A·|¦Û°Ê±À½×¡C
int [ , ] array = new int[,] { {1,2,3}, {4, 5, 6}, {7,8,9} }; // ®ÄªG¤@¼Ë

¦s¨ú¤è¦¡¬O array[1,1] = 10;
³oºØ¼gªk¬Ý°_¨Ó¤Ö¤F´X­Ó[]¡A­Y¹ê»Ú¦L¥X array.Length ´N·|ª¾¹D©MC++¦³«Ü¤jªº®t§O¡C

¤£³W«h°}¦Cªº«Å§i¤è¦¡
int [][] array = new int[3][];
·§©À´N¬O°}¦C¸Ìªº°}¦C¡A¨C­Óºû«×³£¥i¥H³æ¿W°t¸m
array[0] = new int[3];
array[1] = new int [5];
...

°}¦Cªì©l¤Æªº»yªk¡A¥u­nÆ[©À²M·¡¡A¤£·|«ÜÃø
int [][] array = new int [][] {
    new int[] {1,2,3},
    new int[] {4,5,6},
    new int[] {7,8,9}
};

°}¦Cªº¦WºÙ¥u¬O°Ñ·Ó¡A­n³z¹L³o­Ó°Ñ·Ó¥h¦s¨ú­È¤§«e¡A
¤@©w¨Æ¥ý°t¸m¹L°O¾ÐÅé¦ì¸m¤F¡C(new)
°t¸m°O¾ÐÅ骺®É­Ô¡A·íµM­nª¾¹D­Ó¼Æ¦³´X­Ó¡A
­Y¤£¬O¥Ñ³]­p®v«ü©w¡A´N¬O±qªì©l¤Æªº­Ó¼Æ¥h±À½×¡C

TOP

C#ªº°}¦C¬Oª«¥ó, c++ªº¤£¬O

TOP

        ÀR«ä¦Û¦b : ­ì½Ì§O¤H´N¬Oµ½«Ý¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD