Skip to content

ArrayList incorrect remarks #12797

Description

@GeeLaw

Type of issue

Other (describe below)

Description

It says:

Using multidimensional arrays as elements in an ArrayList collection is not supported.

This is factually false. Consider

$al = [System.Collections.ArrayList]::new();
$al.Add([int[,]]::new(2, 2)) | Out-Null;
$al.GetType();    # ArrayList
$al[0].GetType(); # int[,]
$al;              # four 0's

Did the author intend to mean

If you add arrays as elements to an ArrayList al, you cannot access its indexer without casting, so al[0][0] doesn't work. You need to write ((int[,])al[0])[0, 0] if al[0] is int[,].

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.collections.arraylist?view=net-10.0#remarks

Content source URL

https://github.com/dotnet/dotnet-api-docs-temp/blob/live/xml/System.Collections/ArrayList.xml

Document Version Independent Id

6a622c60-e7f9-3105-0b79-96b74ed08569

Platform Id

8cf9e552-6fbf-c688-1a3c-ecf392888b8a

Article author

@dotnet-bot

Metadata

Metadata

Assignees

No one assigned

    Labels

    untriagedNew issue has not been triaged by the area owner

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions