二维数组未声明正确的大小

问题描述 投票:0回答:1

我在这里创建一个新的二维数组。 _console.Buffer.Width 是 960,_console.Buffer.Height 是 360。但是创建的数组始终是 256、144。

glyphBuffer = new Glyph[_console.Buffer.Width, _console.Buffer.Height];
internal readonly struct Glyph
{
    public readonly char Value;
    public readonly int ForegroundIndex;
    public readonly int BackgroundIndex;

    public Glyph(char value, int foregroundIndex, int backgroundIndex)
    {
        Value = value;
        ForegroundIndex = foregroundIndex;
        BackgroundIndex = backgroundIndex;
    }
}

有人知道为什么会发生这种情况吗?

我检查了断点,我 100% 确定是这种情况。

c# arrays multidimensional-array console
1个回答
0
投票

缓冲区尺寸在此过程的后期发生了变化,但数组没有变化。这就是问题所在。

© www.soinside.com 2019 - 2024. All rights reserved.