I'm working on a project to find the number of clusters of ones in a 2D matrix in C#. I want to use a bool array in order to keep track of the "verticies" I have visited using a depth first search.
The issue I am coming across is that I want a 2D bool array where the rows and columns can have different numbers eg. bool[5][4], but c# only allows the bool[,] initialization for 2D bool arrays which has the constraint of the rows and colums having to be the same. Is there a way around this that I'm just not seeing to be able to have a bool array that can have rows and columns of different numbers. Or perhaps a different approach to the problem I have not been able to come up with.
var visited = new bool[,]; //this is working
var visited = new bool[][]; // this does not -- want this so can have
//different numbers of rows and columns