看板 C_Sharp 關於我們 聯絡資訊
目前是想把這樣的資料 011324456789 =>0113 2445 6789 154678987987 =>1546 7898 7987 123456789564 =>1234 5678 9564 每一列 切成3個等分 每份長度4 string[] srAry = new string[3]; ArrayList a1 = new ArrayList(); do { string sr2 = sr.ReadLine(); if (sr2 == null) break; srAry[0] = sr2.Substring(0,4); srAry[1] = sr2.Substring(4,8); srAry[2] = sr2.Substring(8,12); a1.Add(srAry.Clone()); } while (true); ======================= 然後想問一下 接下來要如何從arraylist a1裡面 去取出自己想要的值(譬如想要取出0113 這串字串) 上網有看到JAVA是這樣的作法 double[] ary1={0.212,0.156,0.111,0.915,0.444}; double[] ary2={0.412,0.188,0.711,0.614,0.434}; ArrayList<Object> list = new ArrayList<Object>(); list.add(ary1); list.add(ary2); double[] a = (double[])list.get(0); System.out.println(a[0]); ================== 但c#裡面好像只有GetRange( 0, 5 )用法 如果用Console.WriteLine("{0}", a1.GetRange(0, 4)); 他會顯示 System.Collections.ArrayList+Range 無法顯示出想要的字串 0113 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.168.72.210 ※ 編輯: clipsjess 來自: 118.168.72.210 (04/22 02:30) ※ 編輯: clipsjess 來自: 118.168.72.210 (04/22 02:35) ※ 編輯: clipsjess 來自: 118.168.72.210 (04/22 02:37)
kikiapple:建議:ArrayList --> List<string[]> 04/22 12:37