public static int [,] islands = new int[3,3]{
public static int visited = 100500;
public static int row = 3;
public static int col = 3;
public static void Main()
for(int i=0; i < row; i++){
for(int j=0; j < col; j++)
if(islands[i,j]!=visited && islands[i,j]==1)
Console.WriteLine(islandCounter);
public static void FindIsland(int x, int y)
if( x >= row || x < 0 ){return;}
if( y >= col || y < 0 ){return;}
if(islands[x,y] == 0 || islands[x,y] == visited){
FindIsland(x + 1, y + 1);
FindIsland(x - 1, y - 1);
FindIsland(x + 1, y - 1);
FindIsland(x - 1, y + 1);