ArrayList.add(tmp)循环之后怎么清空临时变量tmp,而不清空结果对象。- rb = {((5016,-1)(5016,-1)(5005,KL41(9) 500x900)(5005,1)(5017,-1)(5016,-1)(5005,KL42(1) 300x800)(5005,1)(5017,-1)(5016,-1)(5005,KL43(2) 500x900)(5005,1)(5017,-1)(5017,-1))}
复制代码 list结果,怎么会是都为最后一项{(KL43(2) 500x900,1) (KL43(2) 500x900,1) (KL43(2) 500x900,1)}
 - //获取双重表值为ArrayList
- public static ArrayList GetLispSymList2(ResultBuffer rb)
- {
- if (rb != null)
- {
- ArrayList list = new ArrayList();
- ArrayList sub = new ArrayList();
- foreach (TypedValue v in (System.Collections.IEnumerable)rb)
- {
- //LispBegin 5016 ListEnd 5017
- if (v.TypeCode == 5016)
- {
- sub.Clear();
- }
- else if (v.TypeCode == 5017)
- {
- list.Add(sub);
- }
- else
- {
- sub.Add(v.Value);
- }
- }
- return list;
- }
- else
- {
- return null;
- }
- }
|