小编tom*_*tom的帖子

如何水平打印数组的内容?

为什么控制台窗口不是水平而不是垂直打印数组内容?

有办法改变吗?

如何以水平方式而不是垂直方式显示数组内容Console.WriteLine()

例如:

int[] numbers = new int[100]
for(int i; i < 100; i++)
{
    numbers[i] = i;
}

for (int i; i < 100; i++) 
{
    Console.WriteLine(numbers[i]);
}
Run Code Online (Sandbox Code Playgroud)

.net c# arrays

67
推荐指数
5
解决办法
25万
查看次数

索引超出了数组的范围

未处理的异常:System.IndexOutOfRangeException:索引超出了数组的边界(在第一个if语句处)

    static int arrayRows = 20;
    static int arrayCols = 20;

    public void printBoard()
    {
        int neighbours;
        for (y = 0; y < arrayCols; y++)
            for (x = 0; x < arrayRows; x++)
            {
                neighbours = 0;
                // Count number of neighbours surrounding live cell
                if (parentGen[x-1, y-1] == 1) // top left 
                    neighbours++;
                if (parentGen[x-1, y] == 1)  // left
                    neighbours++;
                if (parentGen[x-1, y+1] == 1) // bottom left
                    neighbours++;
                if (parentGen[x, y-1] == 1)  // middle top
                    neighbours++; …
Run Code Online (Sandbox Code Playgroud)

c# indexoutofrangeexception

0
推荐指数
1
解决办法
1906
查看次数

标签 统计

c# ×2

.net ×1

arrays ×1

indexoutofrangeexception ×1