如何传递数组列表值 [英] how to pass array list value
本文介绍了如何传递数组列表值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尊敬的先生,
我有一个数组列表.我需要创建一个report.how如何传递数组列表值,如下所示
实际数组列表:
12DBT183843IYP
950.00
12DBT183843YP
1137.00
我需要生成这样的报告
文件编号:金额
12DBT183843IYP 950.00
12DBT183843YP 1137.00
请帮助我
dear sir,
I have a array list. i need to create a report.How to pass array list value like as following
Actual array list:
12DBT183843IYP
950.00
12DBT183843YP
1137.00
I need to generate a report like this
Doc no: Amount
12DBT183843IYP 950.00
12DBT183843YP 1137.00
Please help me
推荐答案
解决方案1也适用于ArrayList
.由于counter i
在for循环内递增,因此我做了一点检查,以确保arr.Length
(对于数组列表arr.Count
)为奇数时循环不会引发错误.
The solution 1 works forArrayList
also. Since, thecounter i
is incremented inside the for loop, I have put a little check to ensure that the loop does not throw error when thearr.Length
(for array listarr.Count
) is odd.
//Better option is to use generic List<string>
//List<string> arr = new List<string>()
//{"12DBT183843IYP","950.00","12DBT183843YP","1137.00","Fifth"};
ArrayList arr = new ArrayList(){"12DBT183843IYP","950.00","12DBT183843YP","1137.00","Fifth"};
for(int i =0;i<arr.Count/2*2;i++)
{
Response.Write(string.Format("<tr><td>{0}</td><td>{1}</td></tr>\n",arr[i++], arr[i]));
}
编写这样的代码,
Write code like this,
for(int i =0;i<arr.Length;i++)
{
write("<tr><td>" + arr[i++] + "</td><td>" + arr[i] + "</td></tr>";
}
请参阅此参考资料
数组列表值 [
see this reference
Array List Values[^]
这篇关于如何传递数组列表值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文