Results 1 to 10 of 10

Thread: Query on ArrayList - How to access

Hybrid View

  1. #1
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Re: Query on ArrayList - How to access

    Quote Originally Posted by Rauland
    Hi
    I´d like to know how to access the data from an arrayList which is inside another arrayList.

    Code:
    //I create two arraylists.
    ArrayList myArray1 = new ArrayList();
    ArrayList myArray2 = new ArrayList();
    
    //Add data to myArray1
    
                myArray1.Add("Array1string1");
                myArray1.Add("Array1string2");
    
    //Add data to myArray2.
    
                myArray2.Add("Array2String1");
    
    //Add myArrayList2 to myArrayList1
    
                myArray1.Add(myArray2);
    My question is , how could I print on screen or access the data from the second array, as per:

    Accessing data from index 0 and 1.
    Code:
              myArray1[0].ToString() +"\n";
              myArray1[1].ToString();
    How would I access data from index 2 ? Which is in this case an arraylist.

    Thanks!
    same as you access as you give in your sample. just put 2 inside the bracket.
    ex. myArray1[2].ToString();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width