C#動(dòng)態(tài)創(chuàng)建數(shù)組實(shí)現(xiàn)實(shí)例解析
C#動(dòng)態(tài)創(chuàng)建數(shù)組不同于VB,那么C#動(dòng)態(tài)創(chuàng)建數(shù)組用到什么方法呢?這里通過一個(gè)實(shí)例向你介紹了C#動(dòng)態(tài)創(chuàng)建數(shù)組的具體實(shí)現(xiàn),希望對(duì)你學(xué)習(xí)C#動(dòng)態(tài)創(chuàng)建數(shù)組有所幫助。
C#動(dòng)態(tài)創(chuàng)建數(shù)組實(shí)例:
- 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]);
C#動(dòng)態(tài)創(chuàng)建數(shù)組的具體實(shí)現(xiàn)就向你介紹到這里,希望對(duì)你了解和學(xué)習(xí)C#動(dòng)態(tài)創(chuàng)建數(shù)組有所幫助。
【編輯推薦】