Skip to content

Improve formatting of multidimensional arrays #991

@jnyrup

Description

@jnyrup

When calling Formatter.ToString(object) on a jagged array such as

new int[][]
{
    new[] { 1, 2 },
    new[] { 3, 4 }
};

the output contains the nested structure as expected.

{{1, 2}, {3, 4}}

Calling Formatter.ToString(object) on a multidimensional array such as

new int[,]
{
    { 1, 2 },
    { 3, 4 }
};

gives an unexpected (and perhaps confusing) visual result, as it doesn't contain the nested structure.

{1, 2, 3, 4}

This could probably be improved by introducing a new MultidimensionalArrayFormatter which checks if the object is an Array and has Rank >= 2.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions