作者clipsjess (blue)
看板C_Sharp
标题[问题] 关於arraylist 取值
时间Tue Apr 22 02:26:10 2008
目前是想把这样的资料
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)
1F:→ kikiapple:建议:ArrayList --> List<string[]> 04/22 12:37