3 回答

TA貢獻1836條經驗 獲得超13個贊
C#動態創建數組不同于VB,C#動態創建數組通過一個實例介紹了C#動態創建數組的具體實現。
C#動態創建數組實例:
1 2 3 4 5 6 7 8 9 10 11 12 13 | ArrayList al = new ArrayList(); al.Add("song"); al.Add("yun"); String[] arr2; arr2 = (String[])(al.ToArray(typeof(String))); System.Diagnostics.Debug.Print("Arr2[0]=" + arr2[0]); //type of int ArrayList al2 = new ArrayList(); al2.Add(23); al2.Add(4); int[] arr3; arr3 = (int[])(al2.ToArray(typeof(int))); System.Diagnostics.Debug.Print("Arr3[0]=" + arr3[0]); |

TA貢獻1898條經驗 獲得超8個贊
C#動態創建數組不同于VB,C#動態創建數組通過一個實例介紹了C#動態創建數組的具體實現。
C#動態創建數組實例:
ArrayList al = new ArrayList(); al.Add("song"); al.Add("yun"); String[] arr2; arr2 = (String[])(al.ToArray(typeof(String))); System.Diagnostics.Debug.Print("Arr2[0]=" + arr2[0]); //type of int ArrayList al2 = new ArrayList(); al2.Add(23); al2.Add(4); int[] arr3; arr3 = (int[])(al2.ToArray(typeof(int))); System.Diagnostics.Debug.Print("Arr3[0]=" + arr3[0]);
- 3 回答
- 0 關注
- 1397 瀏覽
添加回答
舉報