我可以将来自不同for循环的值添加到单个arraylist对象中 [英] Can I add values from different for loop to a single arraylist object

查看:75
本文介绍了我可以将来自不同for循环的值添加到单个arraylist对象中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家,



是否可以将来自不同for循环的多个值添加到单个数组列表对象中。它会提供完整的值还是仅提供最后的值。它的范围是什么。





以下是我在项目中使用的代码....是否正确????

请帮我理解这个。

Hi Experts,

is it possible to add multiple values from different for loops to a single array list object. Will it give complete values or only last value. what is its scope.


Below is the code I am using in my project.... is it correct????
Please help me to understand this.

ArrayList arrInstr = new ArrayList();

for(int i = 0; i < eqpTag1Count; i++)
            {
                if(!String.IsNullOrEmpty(Document.Field("Document Section 1\\Instrument_Tag_Numbers\\Equipment_Tags1[" + i + "]").Text))
               {
                 arrInstr.Add(Document.Field("Document Section 1\\Instrument_Tag_Numbers\\Equipment_Tags1[" + i + "]").Text);
               }
            } 

            for(int i = 0; i < eqpTag2Count; i++)
            {
                if(!String.IsNullOrEmpty(Document.Field("Document Section 1\\Instrument_Tag_Numbers\\Equipment_Tags2[" + i + "]").Text))
               {
                 arrInstr.Add(Document.Field("Document Section 1\\Instrument_Tag_Numbers\\Equipment_Tags2[" + i + "]").Text);
               }
            } 

            for(int i = 0; i < eqpTagDiffCount; i++)
            {
                if(!String.IsNullOrEmpty(Document.Field("Document Section 1\\Instrument_Tag_Numbers\\Equipment_Tags_Diff_Format[" + i + "]").Text))
               {
                 arrInstr.Add(Document.Field("Document Section 1\\Instrument_Tag_Numbers\\Equipment_Tags_Diff_Format[" + i + "]").Text);
               }
            } 





先谢谢..!



Thanks in advance..!

推荐答案

这将为您提供列表中的所有值。

您可以在最后的 .Add 语句中设置断点并检查数组列表中的值。
This will give you all the values in the list.
You can put a break point on the last .Add statement and check the values within the Array List.


这篇关于我可以将来自不同for循环的值添加到单个arraylist对象中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆