c# doubt in ArrayList

Status
Not open for further replies.

Pragadheesh

In the zone
hi everyone,
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Collections;

namespace arraylist
{
    public struct ParameterValues
    {
        public ArrayList al;


    };
    

   public class Program
    {
       public static ArrayList alMix = new 

ArrayList();
       public static ParameterValues pValue = new 

ParameterValues();    
       public static void Main(string[] args)
       { 
           pValue.al = new ArrayList();
            pValue.al.Add(5);
            pValue.al.Add("vgbd");
            pValue.al.Add('d');

            alMix.Add(pValue.al);
            alMix.Add(pValue.al);
//Now i want to ACCESS the elements of alMix array list
           
            Console.ReadKey();
        }
    }
}

in the above program i have created an array list inside the structure and populated it.
The contents gets saved as,
pValue.al[0] = 5
pValue.al[1] = "vgbd"
pValue.al[2] = 'd'

Then i copied those values in another array list alMix where it is getting stored as.
alMix[0][0] = 5
alMix[0][1] = "vgbd"
alMix[0][2] = 'd'
alMix[1][0] = 5
alMix[1][1] = "vgbd"
alMix[1][2] = 'd'

Now since the alMix arraylist is 2D, i'm unable to access it. Please help in accessing the elements of the alMix array list which is 2-dimensional.?

thanx in advance.

no need. i found d solution.
 
Last edited:
OP
Pragadheesh

Pragadheesh

In the zone
something like this.
((ArrayList)alMix)[j]

if we type cast into arraylist its working fine.

link:
*www.dreamincode.net/forums/showtopic43999.htm
 
Status
Not open for further replies.
Top Bottom