Hey, Currently doing a connect four game as a school project and I’m trying to do a function to detect if there is four in a row on the x axis using the following:


The idea is that after every move the function will first check the first row from column 1-4 and see if the next three is the same, otherwise move to the next row. But it wont work and for some reason i will get a out of range in the matrix if I get 3 in a row on the Yaxis. Any ideas what I’m doing wrong?
Can you not initialize the board like new int[3,3]?
Your initialization code creates 7 rows with 6 columns each, but your logic assumes 6 rows with 7 columns. Correct either of them.
C# devs
null reference exceptions

source