The documentation says: "Using multidimensional arrays as elements in an ArrayList collection is not supported." What exactly does this mean? The following code:
var arrayList = new System.Collections.ArrayList();
var item = new int[2, 2] { { 1, 2 }, { 3, 4 } };
arrayList.Add(item);
... normally adds the array to the list. The parameter of ArrayList.Add(value) is object, so it supports adding any object to the list; specifically disallowing multidimensional arrays would seem like an arbitrary limitation. (The elements of the inner array can be retrieved by casting the element, like this: ((int[,])arrayList[0])[1,0] .)
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
ID: 9fa6e8e6-c711-8423-a1b9-3ad1e51484ad
Version Independent ID: 7400ed93-312d-9193-5eb4-512551cb66d9
The documentation says: "Using multidimensional arrays as elements in an ArrayList collection is not supported." What exactly does this mean? The following code:
var arrayList = new System.Collections.ArrayList(); var item = new int[2, 2] { { 1, 2 }, { 3, 4 } }; arrayList.Add(item);
... normally adds the array to the list. The parameter of ArrayList.Add(value) is object, so it supports adding any object to the list; specifically disallowing multidimensional arrays would seem like an arbitrary limitation. (The elements of the inner array can be retrieved by casting the element, like this: ((int[,])arrayList[0])[1,0] .)
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.