I'm using a 2D array of booleans in C#. I've looked up the Array.Exists function at dot net pearls but I can't get it to work, either because I'm using booleans or because it's a 2D array.
bool[,] array = new bool[4, 4];
if (array.Contains(false)) {}; // This line is pseudo coded to show what I'm looking for
                Don't know if this is the proper way or not but casting each element seems to work:
bool[,] a = new bool[4,4]
    {
        {true, true, true, true},
        {true, true, false, true},
        {true, true, true, true},
        {true, true, true, true},
    };
    if(a.Cast<bool>().Contains(false))
    {
        Console.Write("Contains false");
    }
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With