Click here to Skip to main content
15,877,915 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
C#
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..!
Posted
Updated 21-Apr-15 22:42pm
v4

1 solution

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.
 
Share this answer
 
Comments
Mukesh Pr@sad 22-Apr-15 5:00am    
I cannot put break point because I am not using it in Visual Studio.

how can I access any value from this arraylist???
Abhinav S 22-Apr-15 5:26am    
object o = MyArrayList[index];

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900