In C#, i have created ArrayList using structures. so it creates multi dimensional array list.
public struct ParameterValues { public ArrayList al; }; ArrayList alCombined = new ArrayList(); for(int i=0; i < CONDITION , i++) alCombined.Add(obj.pValue.al);
The dimension of ArrayList alCombined depends on the CONDITION. if its 1, then 1-D arraylist is created. Else multidimensional Arraylist is getting created.
Now in order to access the elements of alCombined, i’m typecasting it and accessing, like
(((ArrayList)al[i])[j])
But if its a 1-D arraylist then error occurs as type casting to Arraylist is not possible.
So I need a solution for this, or how to find if its a single/ multi dimensional arraylist. FYI: it should not depend on CONDITION variable. like if d condition is more than one, then it will be multi dimensional for sure.
Thanks in advance.
There’s really no such thing as a ‘multi-dimensional ArrayList’.
ArrayListsdon’t have a particular element type. You might have one element which is an integer, another which is a string, another which is anint[]and another which is anArrayListitself.A few suggestions on your code:
ArrayListis effectively deprecated – use generic collections instead. That will make the type information much more clearer.