You need to cast the dereferenced element, for instance, the following code will work:
ArrayList Myarraylist = new ArrayList();
int [,] array1 = new int[3,2];
int [,] array2 = new int[5,2];
int [,] array3 = new int[6,4];
Myarraylist.Add(array1);
Myarraylist.Add(array2);
Myarraylist.Add(array3);
int[,] Myarray1 = (int[,])Myarraylist[1];
for (int n = 0; n < 2; n++)
Console.WriteLine("MyArray1[0,{0}]={1}", n, Myarray1[0, n]);
BTW as the following note (from
MSDN[
^]) says
Applications that target version 2.0 and later of the .NET Framework should use the generic collection classes in the System.Collections.Generic namespace, which provide greater type-safety and efficiency than their non-generic counterparts.
I strongly suggest you using generic containers instead of
ArrayList
.