小编Eng*_*rer的帖子

如果bool数组中的所有元素都为真?

我在使用这个array.All<>功能时遇到了困难.

private bool noBricksLeft() {
    bool[] dead = new bool[brick.Length];

    for (int i = 0; i < brick.GetLength(0); i++) {
        if (brickLocation[i, 2] == 0)
            dead[i] = true;
        else
            continue; // move onto the next brick
    }

    if (dead.All(dead[] == true)) // IF ALL OF THE ELEMENTS ARE TRUE
        return true;
    else
        return false;
}
Run Code Online (Sandbox Code Playgroud)

我想知道我怎么能实现if (dead.All(dead[] == true))

c# arrays

11
推荐指数
2
解决办法
8099
查看次数

标签 统计

arrays ×1

c# ×1